I am looking for some help with a MYSQL query. I have two tables, one contains a list of tickets and the other is a list of members.
Table Tickets:
ticket_id,
member_id
Table Members:
member_id
A member can but doesn’t have to be assigned to a ticket. What I would like to do is select all the tickets and then if the member_id field is set in the tickets table fetch the member information as well.
One approach is to do a SELECT * FROM Tickets and then loop through in PHP and check if the member_id field is set. If set then do another query on the members table to fetch the corresponding information. The only problem with this is that it would be a large number of queries.
Is there any way to fetch all the results in one join query?
Thanks
1 Answer