Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- a.*,
- rem.nome AS remetente,
- des.nome AS destinatario,
- ure.nome AS ultimo_respondeu
- FROM
- ticket AS a
- INNER JOIN
- usuarios rem ON rem.id = a.remetente_id
- LEFT JOIN
- usuarios des ON des.id = a.destinatario_id
- LEFT JOIN
- usuarios ure ON ure.id = a.ultimo_respondeu_id
- WHERE 1 = 1
- AND
- (SELECT COUNT(*)
- FROM
- usuarios AS b WHERE b.id = a.remetente_id
- AND
- b.tipo = 1 ) >= 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement