I have a sample query with slick as below:
val query =
(for {
(company,loc) <- Company leftJoin Location on (_.locId === _.id)
(_,typeof) <- Company leftJoin Types on (_.typeId === _.id)
} yield (company, loc, typeof))
Is a better way to do multiple joins?
I have tried the suggestions in multiple joins with slick but resulting in errors.
This is working fine.
for {
((company,geo),typeof) <- Company
leftJoin Location on (_.locId === _.id)
leftJoin Business_Levels on (_._1.typeId === _.id)
}
You can chain the join normally :
for {
(company, location, type) <- Company
leftJoin Location on (_.locId === _.id)
leftJoin Types on (_._1.typeId === _.id)
} yield (company, location, type)
And by the way, I am quite sure the word type
is a scala reserved word.
EDIT : Added the _.1 on line 3 after dsr301's comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With