I have a form that contains three fields:
First Name
Surname
Client ID
These three fields relate to three identical fields (first_name, surname and client_id) of the same table in my DB (I'm using MySQL, BTW).
The query I've got so far looks like this:
Code: Select all
SELECT first_name, surname, client_id
FROM client_records
WHERE first_name LIKE '%$first_name%' OR surname LIKE '%$surname%' OR client_id LIKE '%$client_id%'
ORDER BY surname ASCI've already looked at this page
http://dev.mysql.com/doc/refman/5.1/en/ ... earch.html
but I couldn't see anything obvious to solve my problem. Another feature of the search form is that if all fields are left blank then it needs to display all the records. This works with the query that I'm using (because it just has to match '') but fails when I try to use things like MATCH in the query, etc.
Thank you in advance o knowledgeable ones,
Mecha Godzilla