我正在尝试将其编译。.我有一个带有firstname和lastname字段的表,并且我有一个字符串,例如“ Bob Jones”或“ Bob Michael Jones”等。
事实是,例如,我的名字有鲍勃,姓氏有迈克尔·琼斯
所以我想
SELECT neededfield, CONCAT(firstname, ' ', lastname) as firstlast FROM users WHERE firstlast = "Bob Michael Jones"
但是它说未知列“ firstlast” ..有人可以帮助吗?
您提供的别名用于查询的输出-在查询本身中不可用。
您可以重复表达:
SELECT neededfield, CONCAT(firstname, ' ', lastname) as firstlast FROM users WHERE CONCAT(firstname, ' ', lastname) = "Bob Michael Jones"
或包装查询
SELECT * FROM ( SELECT neededfield, CONCAT(firstname, ' ', lastname) as firstlast FROM users) base WHERE firstLast = "Bob Michael Jones"