Skip to content

How to express LEFT JOIN #71

Answered by EvgSkv
tkawachi asked this question in Q&A
Apr 28, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Left join is done via a combine expression. Like this:

JoinedTable(key:, some_value:, joined_value:) :-
  MainTable(key:, some_value:),
  joined_value AnyValue= (x :- OuterTable(key:, value: x));

AnyValue should be used if it is known that OuterTable has no more than one row with the given key.
If it could have many values that List can be used to collect all of them, with appropriate further processing.

I have also added an example in the scripts directory of assembling contacts with the outer join.

Please let me know if you have any questions or comments about this.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tkawachi
Comment options

Answer selected by tkawachi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants