Received: from isdnet01.formanet.be ([195.154.241.134]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAAGQns31785 for ; Fri, 10 Nov 2000 11:26:49 -0500 (EST) (envelope-from cboyanique@formanet.be) Received: from abidos.formanet.loc (vendome.formanet.be [195.154.28.220]) by isdnet01.formanet.be (8.9.3/8.9.3) with ESMTP id RAA24988 for ; Fri, 10 Nov 2000 17:25:32 +0100 Received: from formanet.be (TOF_W98 [192.168.0.200]) by abidos.formanet.loc with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id WDMBCSNB; Fri, 10 Nov 2000 17:29:03 +0100 Message-ID: <3A0C2193.DB793E1B@formanet.be> Date: Fri, 10 Nov 2000 17:25:55 +0100 From: Christophe Boyanique X-Mailer: Mozilla 4.75 [fr] (Win98; U) X-Accept-Language: fr MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id FROM t3) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200011/85 X-Sequence-Number: 116 Hello, I've got a problem with UNION and SELECT IN I have a first table: CREATE TABLE products ( idProduct INT4, name VARCHAR(32) ); and two others tables: CREATE TABLE orders ( id INT4, ts TIMESTAMP ); CREATE TABLE preorders ( id INT4, ts TIMESTAMP ); (I reduced the tables to be as simple as possible) I want to retrieve id of products from the tables orders and preorders; and order it by the name of the product. So I tried: SELECT idProduct FROM products WHERE idProduct IN (SELECT id FROM orders WHERE ts>'2000-10-01 17:04:00' UNION SELECT id FROM preorders WHERE ts>'2000-10-01 17:04:00') ORDER by name; and I've got a parse error near UNION or SELECT depending of the presence of () between the SELECTs. I definitively need some help to solve this problem :-| I asked to a friend to test it with Oracle and that seems to work so I really don't know what to do... Christophe.