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
Missleading select example #3
Comments
Thanks Dumitru. The error isn't that it doesn't use USING, but that it Still needs to be fixed of course... Also it'll need to be added into the Thanks for picking it up I'll fix up the docs. Iain
|
Hi Dumitru, I've commited a change that will resolve this now (although having said that I haven't tested it ;) But basically I just put the table name on the strong_guy_id field in the select, where and order clauses. Thanks! |
Hi Iain, |
If you had a USING instead of an ON clause, you would still get the same On Fri, 4 Sep 2015, Dumitru Uzun wrote:
|
I'm not sure I understand what you mean, but I can run this query (MySQL 5.5.44): SELECT strong_guy_id,weak_guy_id,strong_name,weak_name
FROM strong_guy
INNER JOIN weak_guy USING(`strong_guy_id`)
WHERE strong_guy_id = 1
ORDER BY strong_guy_id,weak_guy_id If I had one more ambiguous field that is not part of |
Oh yeah, you're right. If you have USING then you don't need to prefix each argument with the table name. It would actually be pretty easy for me to change the query builder to use USING instead of ON since it maps the relationships using the key names anyway ... I'll get around to this (at some point!) -- If you want to contribute the fix I'd appreciate it! In the meantime we'll just leave the example so that it doesn't suggest it's using USING behind the scenes. I'll reopen this now and add it to the "TODO" list in the README :) |
… USING for the join then we don't need to prefix key field names in WHERE, FROM and ORDER with the table name
My first experience with Plusql wasn't that good as it could be.
At first glance there is nothing complicated or strange about this example:
But it made me think it uses
USING(strong_guy_id)
internally and I started writting queries with this conviction in my mind, just to discover later that actually this query can't be run as isIt translates to
Which results in an error:
#1052 - Column 'strong_guy_id' in field list is ambiguous
The text was updated successfully, but these errors were encountered: