Shawn
Shawn

Reputation: 47

Error with FROM clause containing a subquery

I was running this query in MSSQL:

SELECT * FROM (SELECT * FROM ABC) 

It gives an error:

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near ')'.

This same command runs just fine on a DB2 database. I know this query doesn't make any sense I was just testing functionality.

So, are there certain features, eg., SELECT in FROM clause, that are not supported in MSSQL that are supported in DB2?

Upvotes: 0

Views: 136

Answers (1)

Alexis Peters
Alexis Peters

Reputation: 1631

You just need to give the subquery an alias like so:

SELECT * FROM (SELECT * FROM ABC) subTable

Which translates to:

SELECT * FROM (SELECT * FROM ABC) as subTable

The AS is optional.

Upvotes: 3

Related Questions