mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +03:00
35 lines
No EOL
493 B
Text
35 lines
No EOL
493 B
Text
SELECT DISTINCT id, class FROM
|
|
(
|
|
(
|
|
SELECT
|
|
recipient_id AS id,
|
|
recipient_type AS class,
|
|
created AS time
|
|
FROM messages
|
|
WHERE
|
|
sender_id = ?
|
|
AND
|
|
sender_type = ?
|
|
AND
|
|
deleted = 0
|
|
) UNION (
|
|
SELECT
|
|
sender_id AS id,
|
|
sender_type AS class,
|
|
created AS time
|
|
FROM messages
|
|
WHERE
|
|
recipient_id = ?
|
|
AND
|
|
recipient_type = ?
|
|
AND
|
|
deleted = 0
|
|
)
|
|
ORDER BY
|
|
time
|
|
DESC
|
|
) dt
|
|
LIMIT
|
|
?
|
|
OFFSET
|
|
? |