MySQL
- 3 ответа
- 0 вопросов
1
Вклад в тег
SELECT ifnull(COUNT ( `dl2`.`dialog_id`),0) AS ` dialog_count`
FROM `dialog_relations` AS `dl1`
INNER JOIN `dialog_relations` AS `dl2` USING(`dialog_id`)
WHERE `dl1`.`user_id` = @user1 AND `dl2`.`user_id` = @user2
SELECT ifnull(COUNT (DISTINCT `dl2`.`dialog_id`),0) AS ` dialog_count`
FROM `dialog_relations` AS `dl1`
INNER JOIN `dialog_relations` AS `dl2` USING(`dialog_id`)
WHERE `dl1`.`user_id` = @user1 AND `dl2`.`user_id` = @user2
SELECT ifnull(COUNT (DISTINCT `dl2`.`user_id`),0) AS ` dialog_count`
FROM `dialog_relations` AS `dl1`
INNER JOIN `dialog_relations` AS `dl2` USING(`dialog_id`)
WHERE `dl1`.`user_id` = @user1 AND `dl2`.`user_id` = @user2