I have a rather long SQL (MySQL flavor) query and want to check if different fields queries have the same name (or alias) like SELECT a, a ...
. Any software for this?
I use Linux.
Software Recommendations Stack Exchange is a question and answer site for people seeking specific software recommendations. It only takes a minute to sign up.
Sign up to join this communityNo software needed. Create a dummy view using your query. If it works, you're good, because views don't support multiple columns with the same name.
CREATE VIEW v1 AS SELECT ...
...your query. If there are duplicate column names, this fails... and gives you one of the duplicate names.
ERROR 1060 (42S21): Duplicate column name 'foo'
Note also that if you have a client library that understands it, a SELECT
query returning multiple columns with the same name is not technically invalid in MySQL, which is why such a query doesn't throw an error if you simply execute it. Not a good thing to do, typically, but not technically invalid.
a
the identical value from the other fielda
? Obviously, you had a problem, or you wouldn't ask. Personally, I don’t see the need for a tool, but, if you want one, that’s fine. Other than a (minor, IMO) performance hit, is this a big thing, which I am unaware of? I am a causal MySql user & always keen to learn