加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

Oracle查询多个表

发布时间:2021-01-26 01:21:55 所属栏目:站长百科 来源:网络整理
导读:我正在尝试显示有义务的志愿者信息以及分配的性能. 我想显示这些信息.但是,当我运行查询时,它没有收集相同性能的不同日期.且availability_date也是混乱的.这是正确的查询吗?我不确定这是正确的查询. 你能给我一些反馈意见吗? 谢谢. 查询就在这里. SELECT P

我正在尝试显示有义务的志愿者信息以及分配的性能.
我想显示这些信息.但是,当我运行查询时,它没有收集相同性能的不同日期.且availability_date也是混乱的.这是正确的查询吗?我不确定这是正确的查询.
你能给我一些反馈意见吗?
谢谢.

查询就在这里.

SELECT Production.name,performance.performance_date,volunteer_duty.availability_date,customer.name "Customer volunteer",volunteer.volunteerid,membership.name "Member volunteer",membership.membershipid
FROM Customer,Membership,Volunteer,volunteer_duty,duty,performance_duty,performance,production
WHERE  
Customer.customerId (+) = Membership.customerId AND
Membership.membershipId = Volunteer.membershipId AND
volunteer.volunteerid = volunteer_duty.volunteerid AND
duty.dutyid = volunteer_duty.dutyid AND
volunteer_duty.dutyId = performance_duty.dutyId AND
volunteer_duty.volunteerId = performance_duty.volunteerId AND
performance_duty.performanceId = performance.performanceId AND
Performance.productionId = production.productionId

– 已添加图片 –
结果:

解决方法

查询似乎是合理的,因为它具有看起来是所有表之间的适当连接条件.我不清楚你对结果有什么问题;如果您更详细地解释和/或显示相关的数据子集,它可能会有所帮助.

但是,由于您说有一些与availability_date相关的问题,我首先想到的是您希望在该列上有一些条件,以确保志愿者在给定性能日期可用于特定任务.这可能意味着只需在查询条件中添加volunteer_duty.availability_date = performance.performance_date即可.

我更一般的建议是从头开始编写查询,一次添加一个表,并使用ANSI连接语法.这将更清楚哪些条件与哪些连接相关,如果您一次添加一个表,希望您将看到结果出错的点.

例如,我可能会从这开始:

SELECT production.name,performance.performance_date
  FROM production
       JOIN performance ON production.productionid = performance.productionid

如果这给出了有意义的结果,那么我将继续为performance_duty添加一个连接并运行该查询.等等.

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!