Bug #11710 Column names with views incorrectly processed
Submitted: 3 Jul 2005 13:29 Modified: 24 Aug 2005 7:20
Reporter: Tim Graves Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.0.7 OS:Windows (WIndows XP)
Assigned to: Assigned Account CPU Architecture:Any

[3 Jul 2005 13:29] Tim Graves
Description:
On selecting from a view using a column alias the names of the returned columns are incorrectly returned as if there is no alias. This occurs in the MySQL command line client and DBVisualizer.

How to repeat:
See the database and scripts I have attached to bug 11709 

select ccbcn.name as CName, rn.name as RName
from ctqContributionByCtqName as ccbcn
inner join requirementName as rn
using (productCode, majorCode, minorCode, requirementCode)
order by CName
LIMIT 5

returns
name	name
Non Applicable / General comments	M801. / Survey. / Q01 Challenges. / Selection is difficult
Non Applicable / General comments	M801. / Survey. / Q01 Challenges. / Customer does not understand what they want
Non Applicable / General comments	M801. / Survey. / Q01 Challenges. / Understanding data driven product definition
Non Applicable / General comments	M801. / Survey. / Q01 Challenges. / Testing prototypes into existence
Non Applicable / General comments	M801. / Survey. / Q01 Challenges. / Eliciting what the software will need to do

Note that the column names are incorrects
[3 Jul 2005 21:39] MySQL Verification Team
mysql> select ccbcn.name as CName, rn.name as RName
    -> from ctqContributionByCtqName as ccbcn
    -> inner join requirementName as rn
    -> using (productCode, majorCode, minorCode, requirementCode)
    -> order by CName
    -> LIMIT 5\G
*************************** 1. row ***************************
name: Non Applicable / Bespoke comments
name: M801. / Survey. / Q01 Challenges. / Bespoke products have specific needs
*************************** 2. row ***************************
name: Non Applicable / Bespoke comments
name: M801. / Survey. / Q10 success / Bespoke developers approvals chain
*************************** 3. row ***************************
name: Non Applicable / Bespoke comments
name: M801. / Survey. / Q03 differences / Requirement gathering differs
*************************** 4. row ***************************
name: Non Applicable / Bespoke comments
name: M801. / Survey. / Q03 differences / Critical functionality identification for bespoke products
*************************** 5. row ***************************
name: Non Applicable / Bespoke comments
name: M801. / Survey. / Q03 differences / Bespoke projects with no requirements are similar
5 rows in set (0.06 sec)

mysql> select version();
+---------------+
| version()     |
+---------------+
| 5.0.9-beta-nt |
+---------------+
1 row in set (0.03 sec)
[31 Jul 2005 11:44] Tim Graves
Looking at the 5.0.10 change log this seems similar to bug 11399, it may be the same problem.
[24 Aug 2005 7:20] Timour Katchaounov
This bug is a duplicate of
  BUG#11399 "Use an alias in a select statement on a view",
which was fixed in 5.0.10.