1
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();

I want to convert this C# LINQ query to SQL query.

join t3 in table3 on new { t1.abc , t2.qwe} equals new { t3.abc , t3.qwe}

I couldn't convert after this part. Is there anyone who can help me?

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • Does this answer your question? [Convert Linq to SQL](https://stackoverflow.com/questions/11716597/convert-linq-to-sql) – Peter Csala Feb 24 '22 at 09:05

2 Answers2

0

Here:

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
C. Coşgun
  • 16
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 24 '22 at 08:28
0

This could be your desired SQL Query

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
Sheikh M. Haris
  • 892
  • 1
  • 9
  • 17