Reputation: 10720
Hi I have a situaltion similar to this
SELECT *
FROM
(
SELECT *
FROM
Table1
)
I wonder why this gives an error
Incorrect syntax near ')'.
Any help ? Thanks in Advance..
Upvotes: 3
Views: 1178
Reputation: 43464
Because you need to add an alias. Run it this way:
SELECT * FROM (
SELECT * FROM Table1
) T
Just for the record, MySQL displays the following error given the same situation :)
Every derived table must have its own alias
Upvotes: 2
Reputation: 11
And you can use the AS keyword to make it more readable
SELECT * FROM ( SELECT * FROM table1 ) as table2
Upvotes: 1
Reputation: 171206
SELECT *
FROM
(
SELECT *
FROM
Table1
) x
You need to give your derived table a name.
Upvotes: 6