MySql subquery

Status
Not open for further replies.

louie

New Member
I have two tables that are not related in any way because it can not be....

I want to select all the records from the first table but only if a certain field in the second table = 'yes'

Any ideas? I am at it for the last half an hour and can't seem to get any results.
 

ziycon

New Member
Try something like the below, works grand for myself on two separate tables. This will return everything from table 1.
Code:
SELECT * FROM tbl1, tbl2 WHERE IF(tbl2.col='value','yes','no')='yes';
 

louie

New Member
Tried that already but not luck.
I get : "Impossible WHERE noticed after reading const tables" from Mysql DB
 

ziycon

New Member
That message is saying that while the where clause is valid an empty result set was returned, are you sure the IF statement is pointing to a valid table/column?
 

ziycon

New Member
Can you throw in 'EXPLAIN' or 'EXPLAIN EXTENDED' in front of the query to get more information from the optimiser?
 
Status
Not open for further replies.
Top