StefIsScared
Programmer
I have the following tables (simplified):
Clients
client_id
client_name
Notes
note_id
note_text
note_date
client_id
Products Purchased
purchase_id
product_id
client_id
A client can only exist once in Clients, but may have multiple notes and purchases. I am trying to get a list of clients and only the most recent product and the date of the most recent note. I thought I could do this with a left join along the lines of ... FROM Clients LEFT JOIN Notes USING(client_id) LEFT JOIN Products Purchased USING(client_id) but that will return multiple rows - for example if there are 5 notes it returns all 5. I can't just do a limit 0,1 etc. as I'd like to get a list of all clients - ideally without looping through and doing individual queries.
I think I am really missing something very simple here?
Clients
client_id
client_name
Notes
note_id
note_text
note_date
client_id
Products Purchased
purchase_id
product_id
client_id
A client can only exist once in Clients, but may have multiple notes and purchases. I am trying to get a list of clients and only the most recent product and the date of the most recent note. I thought I could do this with a left join along the lines of ... FROM Clients LEFT JOIN Notes USING(client_id) LEFT JOIN Products Purchased USING(client_id) but that will return multiple rows - for example if there are 5 notes it returns all 5. I can't just do a limit 0,1 etc. as I'd like to get a list of all clients - ideally without looping through and doing individual queries.
I think I am really missing something very simple here?