请问SQL中三表联查的SELECT语句应该彼样写!?

2025-02-26 22:27:55
推荐回答(2个)
回答1:

SELECT P.ID,P.Name,P.Model,sum(Price_Sub_01),sum(Price_Sub_02) From Products P left join Price01 P01 ON P.ID=P01.Prd_ID left join Price02 P02 ON P.ID=P02.Prd_ID
group by P.id
having sum(Price_Sub_01)=sum(Price_Sub_02)

回答2:

select p.ID, p.Name, p.Model, sum(pa.Price_Sub_01), sum(pb.Price_Sub_02)
from Produces as p,Price01 as pa,Price02 as pb
where p.id=pa.prd_id and p.id=pb.prd_id
group by p.id