openvk/Web/Models/sql/get-messages.tsql
2020-08-01 14:30:08 +00:00

27 lines
388 B
Text

SELECT
*
FROM
`messages`
WHERE
(`deleted` = 0)
AND (`id` > ?)
AND (
(
(`sender_type` = ?)
AND (`recipient_type` = ?)
AND (`sender_id` = ?)
AND (`recipient_id` = ?)
)
OR (
(`sender_type` = ?)
AND (`recipient_type` = ?)
AND (`sender_id` = ?)
AND (`recipient_id` = ?)
)
)
ORDER BY
`created` DESC
LIMIT
?
OFFSET
?