𝕬
Size: a a a
𝕬
БГ
БГ
SELECT DISTINCT to_id, name, text
FROM (
SELECT *
FROM (
select id, from_id as to_id, text
from messages
where to_id == ?
union
select id, to_id, text
from messages
where from_id == ?
)
JOIN users ON
to_id = users.id
ORDER BY id DESC
)
GROUP BY to_id
AF
𝕬
SELECT DISTINCT to_id, name, text
FROM (
SELECT *
FROM (
select id, from_id as to_id, text
from messages
where to_id == ?
union
select id, to_id, text
from messages
where from_id == ?
)
JOIN users ON
to_id = users.id
ORDER BY id DESC
)
GROUP BY to_id
БГ
й
БГ
й
БГ
й
й
import json
БГ
SELECT DISTINCT to_id, name, text
FROM (
SELECT *
FROM (
select id, from_id as to_id, text
from messages
where to_id == ?
union
select id, to_id, text
from messages
where from_id == ?
)
JOIN users ON
to_id = users.id
ORDER BY id DESC
)
GROUP BY to_id
БГ
import json
й
БГ
БГ
A
SELECT DISTINCT to_id, name, text
FROM (
SELECT *
FROM (
select id, from_id as to_id, text
from messages
where to_id == ?
union
select id, to_id, text
from messages
where from_id == ?
)
JOIN users ON
to_id = users.id
ORDER BY id DESC
)
GROUP BY to_id
select m.id, u.name, case when u.id = m.to_id then "TO" else "FROM" end as "direction", m.text from messages m join users u on u.id = m.to_id or u.id = m.from_id where m.to_id = ? or m.from_id = ? order by id desc
БГ
select m.id, u.name, case when u.id = m.to_id then "TO" else "FROM" end as "direction", m.text from messages m join users u on u.id = m.to_id or u.id = m.from_id where m.to_id = ? or m.from_id = ? order by id desc