so suppose I have this query
SELECT COUNT(*) FROM (SELECT * FROM k JOIN j ON k.id = j.aid) k
suppose k and j have two columns with the same name, this entire query will complain with the duplicate columns error....
while simply executing SELECT * FROM k JOIN j ON k.id = j.aid will execute just fine despite the duplicate columns....
I know that you can use USING in the subquery to specify which column to use in case of duplicates, but is there a way to specify the query so that it'll automatically pic a specific column (whether randomly or using whatever rule) to use in case of duplicates without me having to manually specify them?
ie do this without modifying the subquery (SELECT * FROM k etc) and only modify the superquery (SELECT COUNT(*) FROM...) and make it as abstract as possible so that it'll work regardless of what the subquery is
No.
The simplest solution in this example would be to replace * with 1 in the subquery. Is the replacement of a single character really so problematic?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With