khaos337 Posted March 10, 2012 Share Posted March 10, 2012 I'm sure this is a simple solution, but I have been searching for quite some time and can't seem to find a good answer. Basically I have a table with client information, and another table with notes on the client. The table with the notes has 3 columns, clientID which is a foreign key relating the note to the client table, timestamp which shows when the note was written, and note which holds the note text. I want to be able to display a list of clients with only the most recent note (using the timestamp field) displayed. If I do something like this: SELECT c.*, cat.color, cat.name AS catname, n.note, n.timestampFROM client cLEFT JOIN category cat ON cat.ID = c.categoryLEFT JOIN notes n ON n.clientID = c.IDWHERE c.complete = 0 it returns duplicate client records for each note. What is the best way of solving this? Link to comment Share on other sites More sharing options...
astralaaron Posted March 12, 2012 Share Posted March 12, 2012 I think you just need to add something like this in there ORDER BY `timestampField` LIMIT 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.