sqlkata/querybuilder

Update with Joins

SeanLawless opened this issue · 0 comments

Hi,

Just wondering if it is possible to build a query statement to update a table which includes joins. When using the Update() method it compiles fine but does not include the joins in the compiled query.
Example below :

Query("Table1").Join("Table2", "Table2.Column1", "Table1.Column2").Where("Table2.Column3", 1).Update(new {Column5= 1})

Using the compiler this will compile to the blow :

UPDATE [Table1] SET [Column5] = 1 WHERE [Table2].[Column3] = 1

There is no error shown on compilation but it just ignores the joined table completely when run. Can you please advise on a fix for this? From reading the code version one would expect to see the join in the compiled query.

This should be compiling to the following :

UPDATE [Table1] SET [Column5] = 1 FROM [Table1] JOIN [Table2] ON [Table2].[Column1] = [Table1].[Column2] WHERE [Table2].[Column3] = 1

TIA.