Click to See Complete Forum and Search --> : Searching two fields as if they were one


cmwslw
10-12-2008, 05:32 PM
I have two fields in my database called fname (first name) and lname (last name). I was wondering if there was a way where I could search as if they were just one field that had both first name and last name so searches like 'Bob Smith' would turn up. I already tried having "WHERE CONCAT('lname', 'lname') = searchterm", but it didn't work. Any suggestions or will I just have to make another field that has both put together?

chazzy
10-12-2008, 05:44 PM
did you try...


select columns...
from your_table a
WHERE CONCAT(a.fname,' ',a.lname) LIKE '%search term%';


?

cmwslw
10-12-2008, 06:13 PM
That worked great! Thanks for the fast reply.

-Cory Walker