Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
select * from car where carbrand = 'bmw' limit 1 union select * from car where carbrand = 'mercedez'
是否可以在不使用联合的情况下组合此查询?
尝试
SELECT * FROM car WHERE carbrand IN ('bmw', 'mercedez') GROUP BY carbrand
编辑:
SELECT * FROM car WHERE carbrand IN ('bmw', 'mercedez') GROUP BY CASE WHEN carbrand = 'bmw' THEN carbrand ELSE car_id END
看看car_id上面的 ELSE 条件,把它放在你各自的 id 上。
car_id