Question

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.

enter image description here

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.

Was it helpful?

Solution

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.

  1. join() is the same as a SQL INNER JOIN as stated in the javadocs. That matches your picture.

  2. joinOr() is the same as a SQL INNER JOIN but the WHERE parts of the two queries are "OR'd" together as stated in the javadocs. Same picture as #1.

  3. leftJoin() is the same as (wait for it) a SQL LEFT JOIN as stated in the javadocs. That corresponds to adding A to the area in red. See your linked post and look for LEFT JOIN.

  4. leftJoinOr() is the same as a SQL LEFT JOIN as well but the WHERE parts of the two queries are "OR'd" together as stated in the javadocs. Same picture as #3.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top