>>> On Mon, Dec 18, 2006 at 11:48 PM, in message <[EMAIL PROTECTED]>, Tom Lane <[EMAIL PROTECTED]> wrote: > > The reason there's no error thrown is that the reference to mov_id in > the sub- SELECT is a perfectly legal outer reference to the mov_id column > available from the upper SELECT. If the column truly did not exist > anywhere in the tables used in the query, it would have thrown an error. It's easy to see how it resolves the column references; but the syntax is still not compliant with the SQL standard. The FROM clause is required. We could call it a PostgreSQL extension, but I'm curious if anyone actually finds it useful. So far it just seems to provide an opportunity for error. -Kevin *scalar_subquery : subquery ;
*subquery : LEFT_PAREN query_expression RIGHT_PAREN ; *query_expression : non_join_query_expression | joined_table ; *non_join_query_expression : non_join_query_term | query_expression TK_union [ TK_all ] [ corresponding_spec ] query_term | query_expression TK_except [ TK_all ] [ corresponding_spec ] query_term ; *non_join_query_term : non_join_query_primary | query_term TK_intersect [ TK_all ] [ corresponding_spec ] query_primary ; *non_join_query_primary : simple_table | LEFT_PAREN non_join_query_expression RIGHT_PAREN ; *simple_table : query_specification | table_value_constructor | explicit_table ; *query_specification : TK_select [ set_quantifier ] select_list table_expression ; *select_list : ASTERISK | select_sublist [ { COMMA select_sublist }... ] ; *select_sublist : derived_column | qualifier PERIOD ASTERISK ; *derived_column : value_expression [ as_clause ] ; *as_clause : [ TK_as ] column_name ; *table_expression : from_clause [ where_clause ] [ group_by_clause ] [ having_clause ] ; *from_clause : TK_from table_reference [ { COMMA table_reference }... ] ; ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate