Bug #26341 Incorrect column information using SELECT button
Submitted: 13 Feb 2007 20:04 Modified: 22 Feb 2007 12:05
Reporter: Harry Sklar Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.2.9rc OS:Windows (Windows XP)
Assigned to: Mike Lischke CPU Architecture:Any

[13 Feb 2007 20:04] Harry Sklar
Description:
Attempting to build a query using the SELECT button by either double-clicking on a column name or dragging the column name over to the SQL Query Area generates incorrect table reference prefixes for columns in the query after the first one selected. The table reference prefixes pile up at the beginning of the query, and the actual column-names pile up at the end, separately.

For example, for table "pagecontent" and selecting columns one at a time: clicking the first column, "contentID",  works fine:

SELECT p.`contentID` FROM pagecontent p

But as I try to select a second column ("contentItem"), I get the following - notice how "p.," prefix goes to the left of the query for the previously selected column, and only the newly selected column has the correct syntax:

SELECT p., p.`contentItem` `contentID` FROM pagecontent p

Contuning to attempt to select more columns becomes progressively worse:

SELECT p., p., p., p.`isActive` `lastUpdated` `contentItem` `contentID` FROM pagecontent p

How to repeat:
1) Either double-click on a column-name in the righthand Object Browser using the "SELECT" query-building button from the Advanced Toolbar, or drag the column-name over to the SQL Query Area.

2) If only one column is selected, there is no problem with the generated query. For example:

SELECT p.`contentID` FROM pagecontent p

3) But if any additional columns are added to the query, the columns and table reference prefixes start to break. For example:

SELECT p., p., p., p.`isActive` `lastUpdated` `contentItem` `contentID` FROM pagecontent p

Suggested fix:
Correct the "SELECT" query-building button to properly attach the table-reference prefix to each additional column added to the query using this method.

This worked properly in previous versions of the Query Browser I've used, and is the first time I've seen this.
[14 Feb 2007 9:41] Valeriy Kravchuk
Thank you for a bug report. Verified just as decribed on Windows XP SP2.
[18 Feb 2007 20:45] Nicholas Callias
i also came across this problem and found that if one manually deletes the inverted comma, it adds the next field correctly. e.g.:

clicking the first column produces this:

SELECT t.`pk_intClient` FROM tblClient t;

trying to execute this statement gives the error 1064: 
[You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' pk_intClient `pk_intClient` FROM tblClient t' at line 1]

remove the quotes:

SELECT t.pk_intClient FROM tblClient t;

this executes fine and when clicking on the next field to add to the statement, it adds it correctly:

SELECT t.pk_intClient, t.`vchClient` FROM tblClient t;

this also executes fine. however if one wants to add more fields the quotes need to again be manually removed each time.
[22 Feb 2007 12:05] Mike Lischke
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

Duplicate of bug #25943