mySQL: How to select FROM table WHERE IN LIST and NOT IN another list -
is possible select values table, don't exist in 1 list, exist in another... or other way around?
e.g.
select count(g.`property`) `number`, g.`property` `foo` g `theid` in (select `theid` `tableofids` `theid` = '54252') , not in (select `theid` `anothertableofids` `theid` = '54252')
select count(g.`property`) `number`, g.`property` `foo` g `theid` in (select `theid` `tableofids` `theid` = '54252') , `theid` not in (select `theid` `anothertableofids` `theid` = '54252') group g.`property`
alternativly, can use joins perform better:
select count(g.`property`) `number`, g.`property` `foo` g join ( select `theid` `tableofids` `theid` = '54252' ) id1 on g.theid = id1.theid left join ( select `theid` `anothertableofids` `theid` = '54252' ) id2 on g.theid = id2.theid id2.theid null group g.`property`
Comments
Post a Comment