MySQL Search Query on two different fields

后端 未结 4 1129
清歌不尽
清歌不尽 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

    SELECT * FROM users WHERE CONCAT(first_name, ' ', last_name) LIKE '%Ludwig%' OR CONCAT(last_name, ' ', first_name) LIKE '%Ludwig%';

    All search cases where returned including 'Beethoven Ludwig'.

提交回复
热议问题