
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.98 KB | hits: 10 | expires: Never
Select id where all user id match
+ - - - - - - - - - - - + - - - - - +
¦ fk_conversation ¦ fk_user ¦
+ - - - - - - - - - - - + - - - - - +
¦ 1 ¦ 2 ¦
+ - - - - - - - - - - - + - - - - - +
¦ 1 ¦ 3 ¦
+ - - - - - - - - - - - + - - - - - +
¦ 1 ¦ 4 ¦
+ - - - - - - - - - - - + - - - - - +
¦ 2 ¦ 2 ¦
+ - - - - - - - - - - - + - - - - - +
¦ 2 ¦ 4 ¦
+ - - - - - - - - - - - + - - - - - +
select fk_conversation
from my_table
where fk_user in ( ARRAY VALUES )
and fk_conversation in (
select fk_conversation
from my_table
group by fk_conversation having count(distinct fk_user) = ARRAY SIZE
)
group by fk_conversation
having count(distinct fk_user) = ARRAY SIZE;
select fk_conversation
from table
where fk_user in ( comma separated array_values )
group by fk_conversation
having count(fk_conversation) = array_size