I want an easy way to search 2 fields in my database.
Here is the scenario: form has text box called name which can submit a value to search script.
Search script checks name against first and last name fields in database.
Problem I have come across is if people have enter middle names in the database under the first or last name field.
Example of the data i want to search
fname lname
--------------------
stephen jones
john james doe
john james doe
I thought could do a search like this:
SELECT
_leads.Firstname,
_leads.Lastname
FROM
_leads
WHERE
_leads.Firstname LIKE '%stephen jones%' OR
_leads.Lastname LIKE '%stephen jones%'
Well I was hoping it would work.
My other attempt was going to be to explode the string then compare that against the database.
Am I looking too much into this? Is there any easy short bit of code that would help me out?