9

正如标题所示,我想知道如何在in 中设置concat两个字段。这是我想要实现的一个例子:where clausemysql

SELECT CONCAT_WS(' ', first_name, last_name) AS name FROM `users`
WHERE name LIKE "%John Doe%"

关键是first_namelast_name是单独的字段,我想让我的PHP应用程序能够搜索完整的人名。

有小费吗?

干杯!

4

2 回答 2

13

尝试这个 ::

SELECT CONCAT_WS(' ', first_name, last_name) AS name FROM `users`
WHERE CONCAT_WS(' ', first_name, last_name) LIKE "%John Doe%"
于 2012-06-21T14:49:30.660 回答
0

pick up the users as view then query outside select query

select name from (select first_name||last_name FROM `users`
    WHERE frst_name LIKE "%John%" or last name like "%doe%") where name like '%John Doe%'
于 2012-06-21T14:50:44.630 回答