I am currently working on an api using actix_web and diesel in rust. Now to my question; I am trying to make an sql request like this one:
SELECT * FROM customers c
JOIN users u ON u.name = c.customer_no
JOIN address a ON c.fk_address = a.id
WHERE a.name='10715';
There is an actual documentation for multiple joins using diesel but just for implicit joins, which can be found here:
https://docs.diesel.rs/diesel/query_dsl/trait.QueryDsl.html#method.inner_join
Whats the difference between explicit and implicit?
Implicit defines the relationsship via a macro:
users.inner_join(posts)
Explicit defines the relationsship in the query statement:
users.inner_join(posts::table.on(posts::id.eq(user::id)))
Does anyone know how to make a request using multiple explicit joins:
this works:
users.inner_join(posts.inner_join(comments))
this doesn't:
users.inner_join(
posts::table.on(posts::id.eq(user::id))
.inner_join(comments::table.on(comments::id.eq(post::id)))
)