Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id E557E2E009B for ; Tue, 22 Apr 2008 19:11:58 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36660-01-7 for ; Tue, 22 Apr 2008 19:11:52 -0300 (ADT) X-Greylist: delayed 00:43:59.759267 by SQLgrey-1.7.5 Received: from zebedee.cranntara.net (zebedee.cranntara.net [91.186.7.79]) by developer.postgresql.org (Postfix) with ESMTP id 5A47D2E00B4 for ; Tue, 22 Apr 2008 19:11:47 -0300 (ADT) Received: from [62.69.60.46] (helo=localhost) by zebedee.cranntara.net with esmtpsa (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.62) (envelope-from ) id 1JoQ1e-0004RP-PB for pgsql-sql@postgresql.org; Tue, 22 Apr 2008 22:27:43 +0100 Received: from [192.168.0.32] (helo=dick.coachhouse ident=tarlika) by localhost with esmtp (Exim 4.63) (envelope-from ) id 1JoPz7-0003ey-13 for pgsql-sql@postgresql.org; Tue, 22 Apr 2008 22:25:05 +0100 Date: Tue, 22 Apr 2008 22:25:04 +0100 From: Tarlika Elisabeth Schmitz To: pgsql-sql@postgresql.org Subject: extracting words Message-ID: <20080422222504.56bdb06d@dick.coachhouse> X-Mailer: Claws Mail 3.2.0 (GTK+ 2.8.20; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200804/145 X-Sequence-Number: 30684 I am not quite sure whether this would be sensible or indeed at all possible to do in SQL: TABLE product: product_pk, product_name, department_fk TABLE product: department_pk, department_name example data: SELECT product_pk, department_name, product_name ... LEFT JOIN ...: 1, "cakes & desserts", "apple crumble" 2, "cakes & desserts", "cheese cake" 3, "starters & soups", "french onion soup" I need to extract the words from department_name and product_name (words are separated by spaces) and get something like: 1 cakes 1 desserts 1 apple 1 crumble 2 cakes 2 desserts 2 cheese 2 cake 3 starters 3 soups 3 french 3 onion 3 soup Would it be more sensible to produce a table join and split the result into keywords programmatically? -- Best Regards, Tarlika Elisabeth Schmitz A: Because it breaks the logical sequence of discussion Q: Why is top posting bad?