问题
I'm having some issue with understanding join queries in ormlite. ormlite query builder supports 4 join methods.
1. join()
2. joinOr();
3. leftJoin();
4. leftJoinOr();
I can understand join() following picture illustrates join() method.
Please explain me other join methods using similar pictures?
(I can understand other join types in generic SQL, but when it comes to ORMLite query builder methods are different it seems)
Pictures taken from this post.
回答1:
Please explain me other join methods using similar pictures?
I've spent a lot of time on the javadocs. They should be helpful. They explain what SQL is being used and that the "Or" part is.
join()
is the same as a SQLINNER JOIN
as stated in the javadocs. That matches your picture.joinOr()
is the same as a SQLINNER JOIN
but theWHERE
parts of the two queries are "OR'd" together as stated in the javadocs. Same picture as #1.leftJoin()
is the same as (wait for it) a SQLLEFT JOIN
as stated in the javadocs. That corresponds to adding A to the area in red. See your linked post and look forLEFT JOIN
.leftJoinOr()
is the same as a SQLLEFT JOIN
as well but theWHERE
parts of the two queries are "OR'd" together as stated in the javadocs. Same picture as #3.
来源:https://stackoverflow.com/questions/23213173/ormlite-join-queries-with-query-builder