我写了以下查询
SELECT Registration.FName,RequestPooja.RitualId AS RitualId FROM RequestPooja INNER JOIN Registration
ON RequestPooja.UserId = Registration.Id WHERE Registration.Id=2
UNION ALL
SELECT Registration.FName,AaparaKarma.RitualId AS RitualId FROM AaparaKarma INNER JOIN Registration
ON AaparaKarma.UserId = Registration.Id
WHERE Registration.Id=2
产生结果
FName RitualId
Shreyas 24
Shreyas 37
Shreyas 37
Shreyas 37
现在我有一个Rituals表
SELECT Rituals.Id,Rituals.Name FROM Rituals
将输出
Id Name
24 ABC
37 xyz
现在我想对这两个问题进行分析,我希望得到所需的结果
FName RitualId Name
Shreyas 24 ABC
Shreyas 37 xyz
Shreyas 37 xyz
Shreyas 37 xyz
我应该使用连接还是内部查询来获得所需的结果。任何帮助表示感谢。
答案 0 :(得分:0)
检查这个。 使用Join可以提高性能。
contains