I have a search system which helps you filter people list My Table (People)
id | name | surname | email
There is a textbox which you can enter the name, surname or email so the list is filtered as you type.
It finds the records if I write only name or only surname. But if I enter name and surname it does show nothing.
I have tried Mysql's CONCAT function. But it did not work.
My query:
SELECT *
FROM People
WHERE name LIKE :p1
OR surname LIKE :p2
OR email LIKE :p3
I have tried this
SELECT *
FROM People
WHERE name LIKE :p1
OR surname LIKE :p2
OR email LIKE :p3
OR CONCAT(name, char(32), surname) LIKE :p4
and this
SELECT id,
name,
surname,
CONCAT(name, char(32), surname) AS fullname
FROM People
WHERE name LIKE :p1
OR surname LIKE :p2
OR email LIKE :p3
OR fullname LIKE :p4
How can I obtain the system that can find results when name + [space] + surname is entered?
You can split the keywords and search for each individual keyword (or expression) in your columns (name, surname and email).