MySQL Search Query on two different fields

后端 未结 4 1133
清歌不尽
清歌不尽 2021-02-10 03:30

I need to search on two fields using LIKE function and should match also in reverse order. My table uses InnoDB which dont have Full text search.

Consider the following

4条回答
  •  渐次进展
    2021-02-10 03:57

    You need to re-state the concat expression in your where clause.

     SELECT CONCAT(first_name, ' ', last_name) as fullname 
          FROM users 
         WHERE CONCAT(first_name, ' ', last_name) LIKE '%doe%';
    

    Unfortunately "as" just create a column alias, not a variable that you can use elsewhere.

提交回复
热议问题