SELECT * FROM table t1, table t2, table t3, table t4, .... ,table tn
SELECT * FROM table t1, table t2, table t3
SELECT dialog_id FROM members
GROUP BY dialog_id HAVING count(user_id) = 2
AND dialog_id IN (
SELECT dialog_id
FROM members
WHERE user_id = 1 OR user_id = 2
GROUP BY dialog_id HAVING count(user_id) = 2)