var list = (from t1 in table1 ?
join t2 in table2 on t1.xyz equals t2.abc ?
join t3 in table3 on new { t1.abc , t2.qwe} equals new { t3.abc , t3.qwe}
select new Table
{
XYZ= t1.xyz,
ABC = t1.abc,
QWE= t3.qwe
}).Distinct().ToList();
我想將此 C# LINQ 查詢轉換為 SQL 查詢。
join t3 in table3 on new { t1.abc , t2.qwe} equals new { t3.abc , t3.qwe}
在這部分之后我無法轉換。有誰能幫助我嗎?
uj5u.com熱心網友回復:
這里:
Select distinct t1.xyz as XYZ, t1.abc as ABC, t3.qwe as QWE
from table1 as t1
inner join table2 as t2 on t1.xyz = t2.abc
inner join table3 as t3 on t1.abc = t3.abc and t2.qwe = t3.qwe
uj5u.com熱心網友回復:
這可能是您想要的 SQL 查詢
SELECT DISTINCT t1.xyz AS XYZ, t1.abc AS ABC, t3.qwe AS QWE
FROM table1 t1
JOIN table2 t2 ON t1.xyz = t2.abc
JOIN table3 t3 ON t1.abc = t3.abc AND t2.qwe = t3.qwe
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/434890.html
上一篇:執行此排序操作的正確方法是什么?
