I want to write a self join query, However I dunno how to write it in drupal 7 using db_select()
.
The query will look like this
SELECT * FROM msg where sender = receiver
Both sender and receiver fields are part of the msg
table.
I want to write a self join query, However I dunno how to write it in drupal 7 using db_select()
.
The query will look like this
SELECT * FROM msg where sender = receiver
Both sender and receiver fields are part of the msg
table.
A query using db_select
is a lot slower than a 'vanilla' db_query
call...for a query as simple as the one you're doing just run it through db_query:
$query = db_query('SELECT * FROM msg where sender = receiver');
Its possible with the following query,
db_select('msg')
->fields('msg')
->where('sender = receiver');