Using mysql concat() in WHERE clause?

后端 未结 7 2007
旧巷少年郎
旧巷少年郎 2020-11-29 00:59

I would like to search my table having a column of first names and a column of last names. I currently accept a search term from a field and compare it against both columns

7条回答
  •  情深已故
    2020-11-29 01:53

    SELECT *,concat_ws(' ',first_name,last_name) AS whole_name FROM users HAVING whole_name LIKE '%$search_term%'
    

    ...is probably what you want.

提交回复
热议问题