Using mysql concat() in WHERE clause?

后端 未结 7 2008
旧巷少年郎
旧巷少年郎 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:35

    you can do that (work in mysql) probably other SQL too.. just try this:

    select * from table where concat(' ',first_name,last_name) 
        like '%$search_term%';
    

提交回复
热议问题