php - select statement that skips certain rows
158
I need to select data from two tables. However there are two columns, where if one or both rows read NO, I want to skip it.
Table 1
a--b--c-
1 r l
2 t f
3 d c
Table 2
d--e--f--g-
1 r NO NO
2 r YES NO
3 r YES YES
QUERY:
SELECT
talbe1.a,
table1.b,
table1.c,
table2.d,
table2.e,
table2.f,
table2.g,
FROM table1 INNER JOIN
table2 on table1.b = table2.e
WHERE 'no' NOT IN (SELECT table2.f, table2.g FROM table2)
Answer
Solution:
Should be as simple as this:
Answer
Solution:
Try this:
Also not sure about the structure of your tables, but is there a reason you're joining on table1.b = table2.e?
Answer
Solution:
Answer
Solution:
Why not say that f=g and g='YES'?
Answer
Solution:
How about:
Answer
Solution:
You have to Use
LEFT JOIN
notINNER JOIN