WordPressでユーザ情報(wp_users+wp_usermetaからfirst_name,last_name)をSQLで一度に取ってくるSQL

Oct 14, 2015
AD:

WordPressでユーザの情報を名前や、そのほかのもろもろの情報をCSVで出力したかったのですが、そのSQLをメモしておきます。
wp_userテーブルに基本、wp_usemetaに姓、名などの細かい情報が入っているのですが下記のようなテーブル構成になっているので、各種項目を一度に取ってくるには一つ一つをjoinして取ってくるしかないので、メモしておきます。
wp_user_table

SQLはこんな感じです。

もしSQLから直接CSVを書きだしたかったら、参考まにでこちらをどうぞ
MysqlでSelectの結果をCSVにエクスポートする

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 2 | Total: 2 | Feedly: 0

Drupal でSQLを書く – example

Aug 13, 2015
AD:

nodeテーブルからtypeをWhereに入れてSELECT

field_data_field_package_periodテーブルから日付をWhereに入れてSELECT

field_data_field_package_periodテーブルからentity_idをINでSELECT

$results = db_select('field_data_field_package_level', 'fpl')
->fields('fpl', array('field_package_level_value'))
->condition('entity_id', array(1,2,3), 'IN')
->condition('field_package_level_value', 0, '!=')
->execute()

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

Country Code for Rails with Migration

Feb 6, 2013
AD:

I want to setup contry code for my Rails app so I searched by google there are some Gem but I just want to make Tables & Model.
I used data from here

Make migratiton file

Add SQL from here

and then

Done.

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

PostgreSQL 8.1.3→PostgreSQL 9.1.2に変更したらJoinでトラブった件

Mar 23, 2012
AD:

先月、とあるシステムをPostgreSQL 8.1.3→PostgreSQL 9.1.2にアップグレードしたら、既存システムが動かなくなった。
よく調べてみるとSQLのJoin部分のKeyの型がcharacterだと接続エラーになっていました。

解決方法

で、単純に下記のSQLで型を変更しようと思ったのですが、場所によっては下記のSQLでは型変更ができないところがありました。

解決方法(IndexやViewがある場合)

また調べてみると変更しようとしたKeyがIndexやViewの中でも使用されていることが判明
なので、変更対象のKeyが使用されているIndexやViewをいったん削除して、上記SQLを再度実行して、その後に、削除したIndexやViewを復元させて、
事無きを得ました。ちゃんちゃん

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

How to make testing environment about Postgres.

Mar 31, 2009
AD:

I often use postgres server,so sometimes I have to make testing environment for postgres in my windows pc.
So I want to write how to make testing environment about Postgres for my memo.

postgres

First Step

Please login postgres server, and then you have to change user what this user is postgres user.
And I use pg_dump.

-f to write file about output.
-Z。。Number this is level of compression.
-c it is cleaning for schema.

Second Step

You get dump file from server.And then you decompress file.

Third Step

You install postgres in your windows PC. Please check Postgres sites.

Fourth Step

Please copy dump file to there.


And please open command prompt and write this command.

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

初心者用pg_dumpの方法

Apr 30, 2008
AD:

pg_dumpは

を実行すればできると、あるが実際はいろいろと気をつけないことが、たくさんあるのでそのメモ

その一、ユーザの準備
postgresでDBを作成しているなら、postgresユーザがいります。

このときに、ホームディレクトリーも作っておきます。

その二、ファイルの準備
先ほど上のつくったホームディレクトリーの中にdatabase_name.sqlのファイルを作っておきます。

その三、bushが引けてない場合があるのでlocateでpg_dumpを調べてひいいておきましょう。

その四、いざ実行

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 2 | Pocket: 0 | Total: 2 | Feedly: 0

LIKE検索について

Jan 30, 2008
AD:

今までのLIKE検索の仕方

 ↓
こうすればよかったんですね。

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

文字列をSQLクエリー用にエスケープしたい。

Jan 29, 2008
AD:

//Postgresのエスケープ

//Mysqlのエスケープ

Twitter: 0 | Facebook: 0 | Google Plus: 0 | Hatena: 0 | Pocket: 0 | Total: 0 | Feedly: 0

Search Keyword

Meta

face Ayumi Mizoshiri
WEB developer

FacebookPage

Popular Posts

Sorry. No data so far.

ARCHIVES