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%')
Twoje aliasy nie są dostępne dla MySQL podczas pierwszej oceny WHERE
klauzula.
Ale Twoje zapytanie w rzeczywistości jest takie samo:
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%')
Więc twój concat w klauzuli where jest niepotrzebny.