Hello,
I'm having 2 tables, I want to select all values out of table1 where var1=7 (also if they not exist in table2). And in table2 only the values where var2=4.
my sql is:
E.g. table1 where var=7 has 3 values. table2 where var=4 has only 1 value that corresponds with table1. So I want the 3 rows out of table1 and one of the 3 rows also the values out of table2.
You feel me coming... It's not working
.
I hope I explained it correct.
Greetings
visit my website at
I'm having 2 tables, I want to select all values out of table1 where var1=7 (also if they not exist in table2). And in table2 only the values where var2=4.
Code:
table1 table2
ID ID
var1 FK (with table1.ID)
... var2
var3
...
my sql is:
Code:
select table1.*, table2.*
LEFT JOIN table2 ON table1.ID = table2.FK
WHERE (table1.var=7 AND table2.var1=4)
OR (table1.var=7 AND table2.var1 Is Null)
E.g. table1 where var=7 has 3 values. table2 where var=4 has only 1 value that corresponds with table1. So I want the 3 rows out of table1 and one of the 3 rows also the values out of table2.
You feel me coming... It's not working
I hope I explained it correct.
Greetings
visit my website at