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 community
No 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.