I am trying to make a MySQL query where I filter the records based on the search text using LIKE keyword.
For example if the user searches for Illusion Softwares
where Illusion
is First name and Softwares
is last name so the query should search for columns FirstName, LastName and concat both and search.
I have tried this so far but it does not work for CONCAT
Select Contacts.*, Contacts.ID as CID from Contacts left join
website_Data on Contacts.ID = website_Data.ContactID where
Contacts.`FirstName` LIKE '%Illusion Softwares%' or
Contacts.`LastName` LIKE '%Illusion Softwares%' or
concat(Contacts.FirstName, ' ', Contacts.LastName)
LIKE '%Illusion Softwares%'
or Contacts.Email LIKE '%Illusion Softwares%'
order by Contacts.`Created` DESC
What am I missing? Please help me.
Your query should be like this
Select Contacts.*, Contacts.ID as CID
from Contacts
left join website_Data
on Contacts.ID = website_Data.ContactID
where CONCAT(Contacts.FirstName,' ', Contacts.LastName) LIKE '%Illusion Softwares%'
order by Contacts.`Created` DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With