好的,所以我正在从网页中检索 fullname
以过滤客户列表,但我不确定哪个部分是名字或姓氏,因此我需要运行类似下面的查询:
"SELECT sc.*, c.firstname, c.lastname,c.email FROM scoop_customer AS sc LEFT JOIN
customer AS c ON sc.customer_id = c.customer_id WHERE c.firstname + ' ' + c.lastname
LIKE '%".$fullname."%'"
但它似乎对我不起作用,即使我尝试了很多次,通常它应该从 DB 返回值。你能告诉我哪里做错了吗?
最佳答案
尝试 CONCAT
WHERE concat(c.firstname, ' ', c.lastname) LIKE '%".$fullname."%'"
关于php - 在 SQL 中使用 LIKE 运算符时合并字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9825253/