mysql - Select from table A which does not exist in table B -
i trying compose select statement mysql select table not exist in table b. example:
table a:
+------+ | band | +------+ | 1 | | 2 | | 3 | | 4 | | 5 | +------+
table b:
+------+ | hate | +------+ | 1 | | 5 | +------+
so if table bands, , table b bands hate, want bands not hate. result of select should be:
+------+ | band | +------+ | 2 | | 3 | | 4 | +------+
how write single select this? here last attempt:
select * left join b on a.band = b.hate b.hate null;
edit: line above has been fixed! see comments below..."= null" versus "is null".
i use join
select a.* left join b on a.band = b.hate b.hate null;
remember: create appropriate indexes table
Comments
Post a Comment