oracle 是否可以在连接查询中包含双表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12894672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to include dual table in a join query
提问by rktimeless
Is it possible to include the DUAL table in a join query ?
是否可以在连接查询中包含 DUAL 表?
Can anyone give me an example which includes the SYSTIMESTAMP
from dual table.
谁能给我一个例子,其中包括SYSTIMESTAMP
来自双表。
回答by MatBailie
One common use (for me)is to use it to make inline views to join on...
一种常见用途(对我而言)是使用它来制作内联视图以加入...
SELECT
filter.Title,
book.*
FROM
(
SELECT 'Red Riding Hood' AS title FROM dual
UNION ALL
SELECT 'Snow White' AS title FROM dual
)
AS filter
INNER JOIN
book
ON book.title = filter.title
[This is a deliberately trivialised example.]
[这是一个故意琐碎的例子。]
回答by A.B.Cade
Basically you can but there's no need to.
you can add the systimestamp pseudo column to whatever query you already have:
基本上你可以,但没有必要。
您可以将 systimestamp 伪列添加到您已有的任何查询中:
SELECT t.col1, t.col2, systimestamp
FROM your_table t
Will give same results as
将给出相同的结果
SELECT t.col1, t.col2, d.st
FROM your_table t, (select systimestamp st from dual) d
Note that the dual table has only one line, so the cartessian product will not add rows to your original query.
请注意,双表只有一行,因此笛卡尔积不会向您的原始查询添加行。
回答by Paciv
There should be no need to, DUAL
keyword is a way of saying that you're not querying a table, if you want to "join" DUAL
with an other table, just query the other table including your columns that don't come from the table in the select clause.
应该没有必要,DUAL
关键字是一种表示您不是在查询表的方式,如果您想DUAL
与另一个表“连接” ,只需查询另一个表,包括您不来自该表的列在选择子句中。
EDIT :As the comments says, this statement is false, DUAL
is a table.
编辑:正如评论所说,这个陈述是错误的,DUAL
是一张表格。
I still think there is no point in including (from the question)
我仍然认为包括(从问题)没有意义
the DUAL table in a join
连接中的 DUAL 表
回答by Robert
Try this solution:
试试这个解决方案:
select (select SYSTIMESTAMP from dual ) as d
/*
Here you can add more columns from table tab
*/
from tab