Comments on: MySQL joins: ON vs. USING vs. Theta-style https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style Blog by Shlomi Noach Sat, 01 Jul 2017 05:47:56 +0000 hourly 1 https://wordpress.org/?v=5.3.3 By: MySQL joins: ON vs. USING vs. Theta-style - Voyager of Linux https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-394854 Sat, 01 Jul 2017 05:47:56 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-394854 […] https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style […]

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-208761 Thu, 23 May 2013 04:17:20 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-208761 What’s query number two?

]]>
By: Jayesh https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-208701 Wed, 22 May 2013 20:46:30 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-208701 My apologies. I might have posted incomplete question.

query 1:

table_1 join table_2 using(col 1) where table_1.date_1 >= table_2.date_2 and table_1.date_1 >= table_2.date_3 and table_1.date_1 = table_2.date_2 and table_1.date_1 >= table_2.date_3 and table_1.date_1 < table_2.date_4);

What is the difference between the execution and expected results from the 2 queries?

Query 1 returned on 10% of records from query_1 while query 2 returned the desired result.

]]>
By: Jayesh https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-208700 Wed, 22 May 2013 20:41:20 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-208700 Hi,

I had a doubt with respect to the ANSI syntax for join. How would the execution of the query change if i use the two queries given below –

query 1:
table_1 join table_2 using(col 1) where table_1.date_1 >= table_2.date_2 and table_1.date_1 >= table_2.date_3 and table_1.date_1 = table_2.date_2 and table_1.date_1 >= table_2.date_3 and table_1.date_1 < table_2.date_4);

When i used query 1, my total records were reduced from 3 million to 600k. But it was not the case when i used the query 2.

I am unable to understand what went wrong in query 1.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-112203 Mon, 06 Aug 2012 08:44:13 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-112203 @ypercube: you were very clear 🙂

I’m saying this syntax is not allowed in MySQL anyway: you HAVE to put parenthesis with USING.

]]>
By: ypercube https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-112199 Mon, 06 Aug 2012 07:57:21 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-112199 Sorry, I wasn’t clear. I meant that without parenthesis, this would be ambiguous:

FROM film JOIN film_actor USING film_id, x

as to which of the two parenthesized versions above it should be parsed.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-112190 Mon, 06 Aug 2012 06:41:40 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-112190 @ypercube,
In MySQL USING requires parenthesis regardless, so no ambiguities here.

]]>
By: ypercube https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-112134 Sun, 05 Aug 2012 21:34:23 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-112134 I think that the ANSIstyle UISNG syntax requires parenthesis to distinguish the anbiguity:

FROM film JOIN film_actor USING (film_id, x)

(where x is a column)

vs

FROM (film JOIN film_actor USING film_id) , x

(where x is a table)

]]>
By: Roland Bouman https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-107477 Sun, 15 Jul 2012 22:04:12 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-107477 Hi Shlomi – yeah I feel the same, it’s a mess. But I love to tinker away and write queries.

]]>
By: shlomi https://shlomi-noach.github.io/blog/mysql/mysql-joins-on-vs-using-vs-theta-style/comment-page-1#comment-107180 Sat, 14 Jul 2012 04:30:10 +0000 https://shlomi-noach.github.io/blog/?p=5050#comment-107180 Roland,

Great examples on multiple choices (multiple FKs, multiple columns names address_id).

With those examples it becomes very clear how being declarative SQL becomes ambiguous or undefined.

I agree to the notion of RELATE using a FK.

To be honest, I think SQL is a mess. It also uses ancient syntax rules. This doesn’t mean I don’t enjoy it, though 🙂

But it is my belief that ANSI SQL could have been much better if redesigned, in many aspects.

]]>