sql - Find IDs of differing values grouped by foreign key in MySQL -


i have table

process fileds id, fk_object , status.

example

id| fk_object | status ---------------------- 1 | 3         | true 2 | 3         | true 3 | 9         | false 4 | 9         | true 5 | 9         | true 6 | 8         | false 7 | 8         | false 

i want find ids of rows different statusexists grouped fk_object.

in example should return ids 3, 4, 5, because fk_object 9 there existing status true , false , other have 1 of it.

the stock response follows...

select ... ... ... in ('true','false')... group ... having count(distinct status) = 2; 

where '2' equal number of arguments in in()


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -