-1

这是我的表设计

PERSON
DriverID (primary)
DriverName
Address

CAR
RegNO (primary) 
Model 
Year

ACCIDENT
ReportNumber (primary)
AccidentDate
Location

OWNS
DriverID (primary key)  foreign key with PERSON(DriverID)
RegNo (primary Key) foreign key with CAR(RegNo)

PARTICIPATION
DriverID (primary key) foreign key with PERSON (DriverID)
RegNo (primary Key) foreign key with CAR(RegNo)
ReportNumber (primary key) foregin with ACCIDENT(primary)
Damage Amount

现在我想加入所有这些表,所以以下列应该输出 DriverID DriverName Address RegNo Model Year ReportNumber AccidentDate Location DamageAMout

4

1 回答 1

1

尝试这个 ::

Select
* 
from 
participation pt

inner join PERSON p on (p.DriverID = pt.DriverID )
inner join car c on (pt.RegNo =c.RegNo)
inner join accidents a on (pt.ReportNumber =a.ReportNumber)

删除查询是

delete
from 
participation pt

inner join PERSON p on (p.DriverID = pt.DriverID )
inner join car c on (pt.RegNo =c.RegNo)
inner join accidents a on (pt.ReportNumber =a.ReportNumber)
where p.DriverID = 111
于 2012-12-10T05:55:41.317 回答