View Full Version : row search on two columns

10-10-2011, 06:06 PM
I'm trying to figure out how to pull a row that matches a search of two columns.

In other words, if they search for "bob newhart" (in one search field to keep it simple for the user). I want the query to search for bob in first names, and newhart in second names, then combine to show the result.

The query I thought would work, pulled that field, but then seemed to pull every entry after that or something like that. I only want the one row.

Here's what I tried:

"SELECT concat( first_name, ' ', last_name ) AS 'bob newhart' FROM `table`"

10-10-2011, 06:46 PM
neeever mind! I figured it out. This is what I was trying to get:

SELECT * FROM table WHERE CONCAT(first_name,' ',last_name) LIKE 'bob newhart'