question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple left joins fail to work

See original GitHub issue

Using LinqToDB 1.7.6 and a Firebird database. Trying to run a query like:

select *
from shops
left join organizations on ...
left join ocrconfig on ...

C# LINQ code:

var list = (from shop in shops
           join org in orgs on shop.OrganizationId equals org.Id into orgGroup
             join ocr in ocrTable on shop.CustomerNumber equals ocr.CustomerNumber into ocrGroup
            from ocrItem in ocrGroup.DefaultIfEmpty()
            from orgItem in orgGroup.DefaultIfEmpty()
            select new OrgShopPairAdminPn { ShopPn = shop, Organization = orgItem, OcrConfig = ocrItem });

Result: Table not found for ‘LinqToDB.SqlQuery.SelectQuery+Column’

If I only have one left join all is well:

var list = (from shop in shops
            join org in orgs on shop.OrganizationId equals org.Id
            join ocr in ocrTable on shop.CustomerNumber equals ocr.CustomerNumber into ocrGroup
            from ocrItem in ocrGroup.DefaultIfEmpty()
            select new OrgShopPairAdminPn { ShopPn = shop, Organization = org, OcrConfig = ocrItem });

Unfortunately I need left joins here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ilicommented, Mar 2, 2017

This looks like the bug & smells like the bug. Should be reproduced & fixed

0reactions
MaceWinducommented, Mar 25, 2020

Looks like we accidentally fixed it at some point. Works in preview2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple left joins leading to logical error - sql
I am trying to develop a query that counts certain values for multiple tables. The query works fine when I am taking the...
Read more >
Query with two LEFT JOIN's is not working as expected
@joanolo Both subqueries create a recordset with one record for every user_id . The left join should make it work when no transfers...
Read more >
Access SQL: trouble with nested LEFT JOIN and multiple ...
I would like to do a left join using 2 field comparisons, but I can't get it to work, at least when there...
Read more >
How to LEFT JOIN Multiple Tables in SQL
An INNER JOIN will drop records not found on both sides of the join, and you might lose all the records you want...
Read more >
Multiple Left Joins Syntax for Custom SQL
The error seems to be in my JOIN syntax, but I am not very good in SQL and can't figure it out. Any...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found