Subselect in pgSQL

I am trying to do subselect in pgsql aka postgresql and the example I found doesn't work:

SELECT id FROM (SELECT * FROM table);

      

-3


source to share


2 answers


I just needed to add an AS for the subheading, like:



SELECT id FROM (SELECT * FROM table) AS aliasname;

      

+3


source


I think you need something like:

SELECT * FROM table WHERE id IN (SELECT id FROM table2);

      



I don't understand what your non-working subquery is trying to do, it seems like you could just tell SELECT id FROM table

because its currently invalid SQL92 syntax.

+1


source







All Articles