Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Alias syntax in FROM clause #5

Closed
Metalaka opened this issue Jan 15, 2014 · 5 comments
Closed

Alias syntax in FROM clause #5

Metalaka opened this issue Jan 15, 2014 · 5 comments

Comments

@Metalaka
Copy link
Member

MySql throw a SQL syntax error when using from alias on a Select request

#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 'o WHERE o.OBJ_ID = '…' ' at line 1

with request : SELECT OBJ_ID FROM (OBJECTS) AS o WHERE o.OBJ_ID = '…'

Why add parenthesis on line 223 of Hoa\Database\Query\SelectCore ? It work without.

        $this->_from[$alias] = '(' . array_pop($this->_from) . ')';

I doesn't find examples with parenthesis on MySql and MsSql.

This is the syntax from mysql.com.
FROM tbl_name [[AS] alias]

I use MySql 5.5.

PS: there is no comma added between two FORM, this is because Hoa\Database is not finalized?

@Hywan
Copy link
Member

Hywan commented Jan 16, 2014

Hello :-),

What the SQL-2 standard says? This is our reference.
And can you give me an example for your “PS”?

@osaris
Copy link
Member

osaris commented Jan 16, 2014

+1 there's no reason to have parenthesis around the FROM table.

@Hywan
Copy link
Member

Hywan commented Jan 16, 2014

Does it solve your issue 79dffe9?

@Metalaka
Copy link
Member Author

Yes it should.

When there are two or more table in from clause, the syntax should is FROM table1 AS a, table2

@Hywan
Copy link
Member

Hywan commented Jan 16, 2014

I don't have time for a PR now. @osaris or @Metalaka, do you?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants