且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 select 将行添加到查询结果

更新时间:2022-11-27 15:38:07

你这样使用它:

SELECT  age, name
FROM    users
UNION
SELECT  25 AS age, 'Betty' AS name

使用 UNION ALL 允许重复:如果您的用户中有一个 25 岁的 Betty,则第二个查询将不会再仅使用 UNION 选择她.

Use UNION ALL to allow duplicates: if there is a 25-years old Betty among your users, the second query will not select her again with mere UNION.