Expanding Search (Nearest Match)

wxdqz

New Member
Hi

Any suggestions to the following teaser would be appreaciated.

I have a multi table database which I query to retrieve a recordset with the usual SQL syntax.. not a problem.

Now the tricky bit... if there are no/only a few matches, I don't want to display no/those few matches, what I would like, is to retrieve say at least 10 matches/close matches for the query.

Say I want to Query for: a DATE, a NUMBER, A PRICE..

I've explored adjusting the criteria (DATE +1 -1 etc), making the query (between) then checking through the recordset for exact matches and NOT exact matches, one problem is there still no way of being sure you are retrieving the required number of records, apart from checking the number of rows and requerying if neccessary after changing the criteria 'again', but this is pretty unrealistic and resource intensive.

Another way was to return 'all' records with ORDER BY DATE, NUMBER, PRICE

And keep track of the internal Pointer but it hasn't quite clicked.

I am Using PHP 4, Mysql, and a sore head

Thanks in advance

Len
 
Back
Top