I have a ticket made by user 1 with two replies made by user 2 and user 5. Logged as user 4, this query should return 1,2,5 - but it only returns 5 and 2
SELECT DISTINCT `modid`
FROM `comments`
WHERE `tickets_id`='193' AND `modid`!='4'
UNION
SELECT `author` FROM `tickets`WHERE `ticketid`='193';
do you have any idea of why it does this?
Try the following query with join.I don't know exact db structure but by your query I think best you can do is following
SELECT DISTINCT modid
FROM tickets Ticket
INNER JOIN comments Comment ON(Ticket.ticketid=Comment.tickets_id)
WHERE Comment.tickets_id='193' AND Comment.modid!='4'