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%')
Vos alias ne sont pas disponibles pour MySQL lors de la première évaluation de WHERE
clause.
Mais votre requête équivaut en fait à ceci :
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%')
Donc, votre concat dans la clause where est inutile.