桌子objects
id name is_animal
-----------------------
1 dog 1
2 cat 1
3 chair 0
4 rabbit 1
查询
(SELECT name AS animal_name FROM objects WHERE is_animal = 1)
UNION
(SELECT name AS object_name FROM objects WHERE is_animal = 0)
和结果
[animal_name] => dog
[animal_name] => cat
[animal_name] => rabbit
[animal_name] => chair // expected: [object_name] => chair
我已经AS
在第二个 SELECT 中使用过,为什么它返回animal_name
而不是object_name
?