SELECT `dialog_id` FROM `dialogs_users` WHERE `user_id` = '1' AND `dialog_id` IN (
SELECT `dialog_id` FROM `dialogs_users` WHERE `user_id` = '2'
)
SELECT `dialogs_users`.`dialog_id`
FROM `dialogs_users`
-- отсекаем диалоги где `users_count` НЕ <= 2
INNER JOIN
(
SELECT `dialog_id`, COUNT(`user_id`) as `users_count`
FROM `dialogs_users`
GROUP BY `dialog_id`
HAVING `users_count` <= 2
) `t` ON `t`.`dialog_id` = `dialogs_users`.`dialog_id`
-- между юзером с id 1
WHERE `user_id` = '1'
-- и юзером с id 2
AND `dialogs_users`.`dialog_id` IN (
SELECT `dialog_id` FROM `dialogs_users` WHERE `dialogs_users`.`user_id` = '2'
)