SELECT *
FROM
(
SELECT `users`.`firstname`, `users`.`lastname`, `users`.`id`,
CONCAT(firstname," " ,lastname) AS `firstnamelastname`,
CONCAT(lastname," " ,firstname) AS `lastnamefirstname`
FROM `users`
WHERE (id != '15')
)
WHERE (firstnamelastname like 'a%' )
OR (lastnamefirstname like 'a%')
Your aliases are not available to MySQL when it's first evaluating the WHERE
clause.
But your query actually equals this:
SELECT `users`.`firstname`, `users`.`lastname`, `users`.`id`,
CONCAT(firstname," " ,lastname) AS `firstnamelastname`,
CONCAT(lastname," " ,firstname) AS `lastnamefirstname`
FROM `users`
WHERE (id != '15')
AND (firstname LIKE 'a%' OR lastname LIKE 'a%')
So your concat in the where clause is unnecessary.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…