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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -