I’m new to programing and mysql and stuff I think this is simple but not for me So, I have those two table Tickets and Ticket_user and I need to get all the fieds from the Table Ticket where user_id =15 and ticket_id >8
Table 1 : Ticket
id name ...... other fields
7 Tickte1
8 Tickte2
9 ticket3
10 ticket4
11 Tickte5
Table 2 : Ticket_users
id ticket_id User_id
1 7 15
2 8 16
3 9 15
4 10 15
5 11 8
Result
ticket_id name ...... other fields
9 Tickte3
10 ticket4
How can I achieve this ?
appreciate any help.
>Solution :
You need to look into JOIN CLAUSE.
What your looking for is something like this
SELECT t.*
FROM Ticket t LEFT JOIN Ticket_users tu ON t.id = tu.ticket_id
WHERE tu.user_id = 15 AND t.id > 8