I'm having the hardest time with a php (or mysql) search function. I'd be willing to buy a script for that, but i can't find any.
I have a customer table (firstname, lastname, street, zip, city etc....) and i would like to be able to not just look for one keyword but for 2 IN 2 DIFFERENT columns.
for instance:
Keyword: "John Doe"
So my attempt was.
SELECT ....
WHERE CONCAT(firstname,lastname) LIKE '%john%'
AND CONCAT(firstname,lastname LIKE '%doe%'
However: that gives me back all johns and does and Mr. John Doe is somewhere in that list, but not on top, even though it's supposed to be the most relevant result.
I also tried:
....
WHERE MATCH(firstname,lastname) AGAINST('%john doe%')
And that pretty much gives back the same result.
So the result I'm looking for would be:
1. John Doe (at first position!)
2. John Miller
3. John Smith
4. Harry Doe
5. Jack Doe
etc......
I've been looking for 2 hours and i refuse to believe I'm the first person who ever tried to do that :-)
Any help is appreciated!
Thanks!