I'm trying to make a simple search engine to search a list of names in a database.
The names are stored in two columns, first_name and last_name.
I plan on using a simple LIKE statement using the exploded results from the search box to create the query.
But because the first names and last names are stored in separate columns I want to concatinate the two columns BEFORE I apply the LIKE condition so its as if I'm searching for results from a single column.
I thought of using:
Code: Select all
SELECT CONCAT(first_name, last_name) AS name FROM users WHERE name LIKE '%john%' OR name LIKE '%smith%'Can anyone tell me how to do this?