Are there any other way of doing this query:
SELECT CONCAT_WS(\" \", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
WHERE lessor = \'$less
In MySQL, you cannot use the alias near WHERE.
This will work.
SELECT * FROM (SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor) AS t1
WHERE lessor_name = '$lessor_name'
It might be due to lessor
instead of lessor_name
in where clause. So try with below once :
SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
having lessor_name= '$lessor_name'
maybe this will work:
SELECT CONCAT_WS(" ", strLname, strFname, strMname) AS lessor_name
FROM tbl_lessor
WHERE CONCAT_WS(" ", strLname, strFname, strMname) = '$lessor_name'