还有其他方法可以执行此查询:
SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
WHERE lessor = '$lessor_name'
我尝试了但是在mysql中显示了未知列的错误
答案 0 :(得分:10)
可能是由于lessor
而不是where子句中的lessor_name
。所以请尝试以下一次:
SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
having lessor_name= '$lessor_name'
答案 1 :(得分:4)
在MySQL中,您不能使用 WHERE 附近的别名。
答案 2 :(得分:2)
也许这会奏效:
SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
WHERE CONCAT_WS(" ", strLname, strFname, strMname) = '$lessor_name'
答案 3 :(得分:0)
这样可行。
SELECT * FROM (SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor) AS t1
WHERE lessor_name = '$lessor_name'