Description:
When doing a query that contains both * and a function (UTC_TIMESTAMP(), IF(), etc...), the order in the select causes different result. In some cases, it works, in the other, it will cause ERROR 1064.
Works:
1. SELECT *,IF(...) FROM ...
2. SELECT IF(...), t.* FROM ... as t
3. SELECT IF(...), t.* FROM t
Causes Error 1064:
1. SELECT IF(...),* FROM ...
How to repeat:
Here is the example, I used a "in-bedded" table, but any table will cause the problem:
mysql> select UTC_TIMESTAMP(),* from (select 1 from dual) as t;
ERROR 1064 (42000): 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 '* from (select 1 from dual) as t' at line 1
mysql> select UTC_TIMESTAMP(),t.* from (select 1 from dual) as t;
+---------------------+---+
| UTC_TIMESTAMP() | 1 |
+---------------------+---+
| 2008-12-04 16:26:15 | 1 |
+---------------------+---+
mysql> select *,UTC_TIMESTAMP() from (select 1 from dual) as t;
+---+---------------------+
| 1 | UTC_TIMESTAMP() |
+---+---------------------+
| 1 | 2008-12-04 16:26:28 |
+---+---------------------+