本文介绍了如何选择几个硬编码的SQL行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果执行此查询
SELECT 'test-a1' AS name1, 'test-a2' AS name2
结果将是具有两列的单行选择,其值分别为:
the result will be a one row-selection with two columns having these values:
test-a1, test-a2
如何修改上面的查询,使其具有多行选择,例如
How can I modify the above query to have a selection with several rows, e.g.
test-a1, test-a2
test-b1, test-b2
test-c1, test-c2
我知道如何使用UNION进行此操作,但是我觉得存在一种更简单的方法.
I know how to do this with UNION but I feel that there exists a more simple way to do it.
PS.很抱歉遇到这样一个基本问题,很难谷歌搜索它.
PS. Sorry for such a basic question, it is very hard to google it.
推荐答案
UNION ALL是最好的选择.它比UNION快,并且您将拥有互斥的行.
UNION ALL is the best bet. It's faster than UNION and you will have mutually exclusive rows.
这篇关于如何选择几个硬编码的SQL行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!