我在做Oracle数据库项目,名为“Theatre booking system”。 我想通过Customer_Concession和Member_Concession显示折扣价格。 可以使用的外键是Ticket表中的bookingId,cconcessionId和mconcessionId。 我想要显示所有票证,即使其中一个id不存在。 如何编写SQL? 你能帮我吗? 谢谢。Oracle Sql开发人员如何显示空的外键
SELECT t.ticketId, pro.name "Production name", PRICE.LEVELID "Price level",
Price.price "Price", (Price.price - ccons.discountPrice - mcons.discountPrice)
"Discounted Price", t.seatNo "Seat", t.rowNo "Row", t.block "Block",
per.performance_date "Performance date", per.start_time "Start time",
per.end_time "End time", t.availability "Availability"
FROM Ticket t, Production pro, Performance per, Price, Price_level,
Booking, Customer, Customer_Concession ccons, Member_concession mcons
WHERE t.performanceid = per.performanceid AND
t.PRODUCTIONID = Price.PRODUCTIONID AND
t.levelId = Price.levelId AND
Price.PRODUCTIONID = pro.PRODUCTIONID AND
Price.levelId = Price_level.levelId AND
t.bookingId = Booking.bookingId AND
Booking.customerId = Customer.customerId AND
ccons.cconcessionId = t.cconcessionId AND
mcons.mconcessionId = t.mconcessionId
ORDER BY t.ticketId
Oh..it很容易解决!谢谢! – wholee1 2012-03-26 20:28:37