X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id A1F3230E9A5 for ; Thu, 19 Jun 2003 16:38:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 87733-09 for ; Thu, 19 Jun 2003 13:37:50 -0300 (ADT) Received: from vadangyal.vnet.hu (mail.vnet.hu [213.163.59.4]) by svr1.postgresql.org (Postfix) with ESMTP id B76B730E8F3 for ; Thu, 19 Jun 2003 13:37:49 -0300 (ADT) Received: from compaq (adsl243046.vnet.hu [62.77.243.46]) by mail.vnet.hu (iPlanet Messaging Server 5.1 Patch 1 (built Jun 6 2002)) with ESMTPA id <0HGQ0054ZM559S@mail.vnet.hu> for pgsql-general@postgresql.org; Thu, 19 Jun 2003 18:36:42 +0200 (CEST) Date: Thu, 19 Jun 2003 18:36:10 +0200 From: =?iso-8859-1?Q?Egy=FCd_Csaba?= Subject: SQL question To: pgsql-general@postgresql.org Reply-To: =?iso-8859-1?Q?Egy=FCd_Csaba?= Message-id: <000801c33680$e7f56a00$230a0a0a@compaq> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 X-Mailer: Microsoft Outlook Express 6.00.2720.3000 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT X-Priority: 3 X-MSMail-priority: Normal References: X-Archive-Number: 200306/1274 X-Sequence-Number: 44202 Hi All, I have a problem. I have 3 tables. 1. stock changes 2. product groups 3. a link table between the 2 above I need the name of the product group the product belongs to, which product is the subject of the stock change. (I hope it's understandable) So I tried this query: ---------------------------------------------------------------------------- ------------------ DB=# select t_stockchanges.productid, (select name from t_productgroups where id=(select productgroupid from t_prod_in_pgr where productid=t_stockchanges.productid)) as pgroup from t_stockchanges; ---------------------------------------------------------------------------- ------------------ As I suppose this query should have produced 2 columns, the productid and the related product group name: pgroup. But instead it generated an error. It says, that the subquery (I suppose the most inner) gives back more then 1 tuple. How can I query the only 1 record, that matches the actual t-stockchanges records productid field. Isn't it calculated for each stockchanges record? Thank you in advance. Best Regards, -- Csaba --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.489 / Virus Database: 288 - Release Date: 2003. 06. 10.