C# SQL完全联接6个表
我有几张桌子。有人能告诉我必须使用哪个连接吗C# SQL完全联接6个表,c#,mysql,sql,C#,Mysql,Sql,我有几张桌子。有人能告诉我必须使用哪个连接吗 Table Factory : FactoryId, FactoryName Table Person: PersonId, PersonName Table Activity : AcitivityId, AcitivityType Table FactoryPersonActivity: FactoryID, PersonId, ActivityId Table AcitivityLead: AcitivityId, LeadId Ta
Table Factory : FactoryId, FactoryName
Table Person: PersonId, PersonName
Table Activity : AcitivityId, AcitivityType
Table FactoryPersonActivity: FactoryID, PersonId, ActivityId
Table AcitivityLead: AcitivityId, LeadId
Table Lead: LeadId, LeadType, LeadMethod
现在的问题是:我想要某个工厂的所有线索(细节)。有人能告诉我join语句必须是什么吗
提前谢谢 试试这个:
SELECT
l.LeadType,
l.LeadMethod
f.Name
p.PersonNASme,
...
FROM Factory f
INNER JOIN FactoryPersonActivity fpa ON f.FactoryId = fpa.FactoryID
INNER JOIN Person p ON fpa.PersonID = p.PersonId
INNER JOIN Activity a ON fpa.ActivityID = a.ActivityId
INNER JOIN AcitivityLead al ON a.AcitivityId = al.AcitivityId
INNER JOIN Lead l ON a.LeadId = al.LeadId
WHERE f.FactoryID = $id;
请阅读有关加入的更多信息: