Oracle查询多个表

who*_*ee1 5 oracle

我正在尝试显示有义务的志愿者信息以及分配的性能.我想显示这些信息.但是,当我运行查询时,它没有收集相同性能的不同日期.且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
Run Code Online (Sandbox Code Playgroud)

- 已添加图片 - 结果: 在此输入图像描述

Dav*_*sta 5

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

但是,既然你说有一些相关的问题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
Run Code Online (Sandbox Code Playgroud)

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