Oracle数据库查询调整
我有一个很大的SQL查询,并且难以管理,我需要的帮助IFI可以做任何事情 -
将内部查询存储在变量中,并在外部查询中使用变量作为参考示例示例
var1 = select * from customer
var2 = select * from product
var3= select custid from var1
and finally
select a.customername,b*,c* from var1 as a, var2 as b , var3 as c where a.custid = c.c_id and
a.custid = b.custid
注意我不是数据库人员,我是Java程序员
I have a big sql query and its difficult to manage, what I need help ifI can do anything like -
store the inner queries in variables and use variable as reference in the outer queries example
var1 = select * from customer
var2 = select * from product
var3= select custid from var1
and finally
select a.customername,b*,c* from var1 as a, var2 as b , var3 as c where a.custid = c.c_id and
a.custid = b.custid
Note I am not a database person, I am a java programmer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用CTE(常见表表达式)来简化主查询。例如,您的查询可以改写为:
主要查询可以参考任何CTE(
a
,b
或c
)) 。每个CTE都可以提及先前定义的CTE。在您的示例中,第三个可能会引用第一个。You can use CTEs (Common Table Expressions) to simplify the main query. For example, your query can be rephrased as:
The main query can have references to any of the CTEs (
a
,b
, orc
). Each CTE can alse have references to the previously defined CTEs; in your example, the third one will probably reference the first one.