Query all records, where foreign reference does NOT exist

Options

Hi,

I'm trying to do a query in table A, where table B does not have a record with a column pointing to table A. I'm looking around the inner join queries but don't see an obvious way to do it. Ideas?

Best Answer

  • sepirak-nick
    sepirak-nick Member
    Answer ✓
    Options

    As often happens, I found the solution before waiting for an answer.

    I used a combination of inner join and the custom query. For some reason I thought I couldn't use custom query on tables that were joined, but you can. So I did a "left" join, enabled the option to "IGNORE EMTPY VALUES", then in custom query I did a queried where A.id == null (or, in my case, I did have an exception where if row A existed it could be included in the results if A.foo == "specific_value").

Answers

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Glad you solved it 😊 and thank you for sharing the answer! Always super helpful when other people are looking to solve for the same question!