-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatible error when grouping on join #25041
Comments
This is specific to the use of mysql [localhost:8024] {msandbox} (test) > select id, count(*) from t1 join t2 using (id) group by id;
Empty set (0.00 sec)
mysql [localhost:8024] {msandbox} (test) > select id, count(*) from t1 join t2 on t1.id=t2.id group by id;
ERROR 1052 (23000): Column 'id' in field list is ambiguous I am not sure how these are different. I would have thought it's functionally the same. |
The behavior of NATURAL JOIN is the same as USING. I tested this at https://www.db-fiddle.com/ on Postgres and SQLite and they have the same behavior as MySQL, so we're the outlier here. Let's fix it! |
Morgan found that MySQL actually rewrites the query with USING() so that https://gist.github.com/morgo/cc229e891c0abd0563b78b93ffb10cca |
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versions |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
This query should return results, because there cannot be any ambiguity when grouping on a column that is covered by the join condition.
3. What did you see instead (Required)
This type of query can execute without any error in MySQL:
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: