gpt4 book ai didi

php - 在 SQL 中使用 LIKE 运算符时合并字段

转载 作者:行者123 更新时间:2023-12-01 00:28:23 25 4
gpt4 key购买 nike

好的,所以我正在从网页中检索 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com