I'm using this SQL query to go through a table and search for a customer name and return that row's id and date column:
SELECT custName, date, id FROM booking
WHERE custName LIKE '%$s'
OR custName LIKE '$s%'
($s being a PHP variable)
If I'm looking for John Dorian, I could input $s as the first name John, or family name Dorian and my function will find him. My problem is that John Dorian may appear in more than one row, and if that's the case I would like the query to return only the most recent row (using the date column to figure this out).
IE if my table looks like this and $s = John:
(custName, date, id)
John Dorian - 2013/01/01 - 1
John Doe - 2013/01/02 - 2
John Dorian - 2013/01/10 - 3
I would like my query to return
John Doe - 2013/01/02 - 2
John Dorian - 2013/01/10 - 3