Searching on full name with firstname lastname columns

My users are stored in the database with a firstname lastname. For this project I need to be able to search on their full name like, “David Jones”.

I’ve used concat a little bit to produce a full name in the query results, but is the same thing possible when searching?

Thanks!


SELECT
    concat( firstName, ' ', lastName ) AS fullName
FROM yourTable
WHERE fullName LIKE ......

#1054 - Unknown column ‘fullName’ in ‘where clause’

yeah, you can’t use a SELECT clause column alias in the WHERE clause

you have to do this –

SELECT CONCAT( firstName, ' ', lastName )
              AS fullName
  FROM yourTable
 WHERE CONCAT( firstName, ' ', lastName ) LIKE ...

alternatively, this –

SELECT fullName
  FROM ( SELECT CONCAT( firstName, ' ', lastName )
                     AS fullName
           FROM yourTable ) AS d
 WHERE fullName LIKE ...

Oops my wrong! Thanks rudy