some context I asked a question about a MySQL request, my post can be found there: Need help about joining tables
Now I have another problem related to that, so on my pa
Instead of filtering on an exact userid, you should check if the user is related to the issue, like this:
select
t.title,
group_concat(
case when tu.type = 1 then
concat(u.firstname, ' ', u.lastname)
end) as creator,
t.priority,
t.date,
group_concat(
case when tu.type = 2 then
concat(u.firstname, ' ', u.lastname)
end SEPARATOR ' - ') as users
from
tickets t
inner join tickets_users tu on tu.ticketid = t.id
inner join users u on u.id = tu.userid
where
exists (
select
'x'
from
tickets_users tu2
where
tu2.ticketid = t.id and
tu2.userid = and
tu2.type = 1)
group by
t.id;
For
you can fill in the user id you want. This query will return all issues that are reported by that user (type = 1). But for all those issues, still all related users are returned, so your query result is still complete.