"Klaus Guntermann" <[EMAIL PROTECTED]> writes: > with the following simplified example I get a false error message in the > second select statement, which is almost like the first one.
> select dummy.myfield from dummy where dummy.myfield=1 union > select dummy.myfield from dummy where dummy.myfield=2 order by > dummy.myfield; It's complaining about the invalid qualification of the ORDER BY item. An ORDER BY attached to a UNION can only use unqualified column names of the UNION result (ie, it should just be "ORDER BY myfield" or "ORDER BY 1"). I agree that "missing FROM-clause entry" isn't the best possible error message for that, but it doesn't look simple to improve it. FWIW, CVS tip (8.2 to be) gives an error cursor pointing at the ORDER BY item: regression=# select dummy.myfield from dummy where dummy.myfield=1 union regression-# select dummy.myfield from dummy where dummy.myfield=2 order by regression-# dummy.myfield; ERROR: missing FROM-clause entry for table "dummy" LINE 3: dummy.myfield; ^ regression=# which should help at least a little. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings