The table objects
id name is_animal
-----------------------
1 dog 1
2 cat 1
3 chair 0
4 rabbit 1
The query
(SELECT name AS animal_name FROM objects WHERE is_animal = 1)
UNION
(SELECT name AS object_name FROM objects WHERE is_animal = 0)
and the result
[animal_name] => dog
[animal_name] => cat
[animal_name] => rabbit
[animal_name] => chair // expected: [object_name] => chair
I’ve already used AS in the second SELECT, why does it return animal_name instead of object_name?
with
UNION:with
case: