Bug #31368 before-JOIN word can be virtually any word
Submitted: 3 Oct 2007 12:18 Modified: 3 Oct 2007 16:30
Reporter: Mattia Merzi Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:mysql.exe Ver 14.12 Distrib 5.0.37 OS:Windows (XPSP2)
Assigned to: CPU Architecture:Any
Tags: join, SQL Syntax

[3 Oct 2007 12:18] Mattia Merzi
Description:
Hi,

it seems to me quite strange, and AFAIK does not complain with specs,
that I can write virtually anything before the JOIN word.
A very simple example:
mysql> SELECT * FROM A foobar JOIN B;
+------+------+
| X    | X    |
+------+------+
|    1 |    2 |
|    1 |    3 |
|    2 |    2 |
|    2 |    3 |
|    3 |    2 |
|    3 |    3 |
+------+------+
6 rows in set (0.00 sec)

Well, if this is a feature, maybe the syntax spec. is wrong:
http://dev.mysql.com/doc/refman/5.0/en/join.html

How to repeat:
CREATE TABLE A(
	X INT
);

CREATE TABLE B(
	X INT
);

INSERT INTO A(X) VALUES (1);
INSERT INTO A(X) VALUES (2);
INSERT INTO A(X) VALUES (3);
INSERT INTO B(X) VALUES (2);
INSERT INTO B(X) VALUES (3);

SELECT * FROM A
foobar JOIN B;
[3 Oct 2007 16:30] Jim Winstead
You're just aliasing the table A as 'foobar' in your example. See the expansion of table_factor on the page you referenced.