To be precise: those aren't "sub-queries", it's called a "derived table". And the first one is invalid because you have a ; inside the derived table. What exactly is the error message you get (when running the second one)? If I had to guess: you need to supply an alias for the derived table: select * from (select * from mytable ) as t
- a_horse_with_no_name
1 Answers
12
votes
@a_horse_with_no_name has pointed out clearly. It should be written like this.
SELECT *
FROM
(
SELECT *
FROM mytable
) as MY_TABLE;
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more
;inside the derived table. What exactly is the error message you get (when running the second one)? If I had to guess: you need to supply an alias for the derived table:select * from (select * from mytable ) as t- a_horse_with_no_name