full join "using" list of columns
Hey,
How can I create a full join which uses "using"
I want to use "using" in the join but I only see "on", maybe I can acheive this using sql
using
, what is the correct way ?
example:
Solution:Jump to solution
```ts
.innerJoin('b', join => join
.onRef('a.foo', '=', 'b.foo')
.onRef('a.bar', '=', 'b.bar')
)...
9 Replies
USING foo
is just ON a.foo = b.foo
USING (foo, bar)
is just ON a.foo = b.foo AND a.bar = b.bar
Solution
i tried it but I don't seem to get the same answer using "on" and using
so something is missing
because I try to join 3 tables and it does not have the same result set
The second join is joining against first two tables
what do you mean ?
Well you should probably know what your query is doing right? The second join joins against the joined set, not just a single table.
try this
you get different results
😄
That's what I'm saying. You need to join agains the whole joined set. Not just one table
The second
using
join is joining agains the whole set at that point. Not just table a
or b
but both.can I do raw sql inside the join ?
is there any way of using "using" @koskimas ?