Bug #9250 Query builder use reserved words as table alias
Submitted: 17 Mar 2005 14:34 Modified: 2 Jun 2005 9:36
Reporter: Emanuele Dolis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.1.5 OS:Windows (Windows XP SP2)
Assigned to: Vladimir Kolesnikov CPU Architecture:Any

[17 Mar 2005 14:34] Emanuele Dolis
Description:
Sometimes Query builder uses aliases like "to" which raises a query execution error since it's a reserved word.
See example.

How to repeat:
a) create suitable tables
____________________________
USE test;

 DROP TABLE IF EXISTS `tb_cst`;
CREATE TABLE `tb_cst` (
  `KyCst` mediumint(6) unsigned zerofill NOT NULL default '000000' ,
  `CstDE` mediumint(6) unsigned zerofill default NULL ,
  PRIMARY KEY  (`KyCst`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='CUSTOMERS Table';

DROP TABLE IF EXISTS `tb_con`;
CREATE TABLE `tb_con` (
  `KyCst` mediumint(6) unsigned zerofill NOT NULL default '000000' ,
  `KyCon` mediumint(5) unsigned zerofill NOT NULL auto_increment,
  PRIMARY KEY  (`KyCst`,`KyCon`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
__________________________
b) start composing a query con query creator: first drag and add tb_cst
c) now add table tb_con, using drag & drop on the inner join button
d) note the result:

SELECT * FROM tb_cst t, tb_con to
WHERE to.KyCst=t.KyCst

this query is malformed - "to" as an alias is a reserved word.
[17 Mar 2005 15:22] Jorge del Conde
Thanks for the bug report.

Its "Join Table", not "Add Table"
[2 Jun 2005 9:36] Vladimir Kolesnikov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html