X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DB1999FADD1 for ; Mon, 1 May 2006 06:16:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 25694-09 for ; Mon, 1 May 2006 06:16:34 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E52069FA619 for ; Mon, 1 May 2006 06:16:34 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 5BCC630DB7; Mon, 1 May 2006 11:16:31 +0200 (MET DST) From: Sim Zacks X-Newsgroups: pgsql.sql Subject: join on a like Date: Mon, 01 May 2006 12:14:21 +0200 Organization: Hub.Org Networking Services Lines: 15 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Thunderbird 1.5 (Windows/20051201) To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/28 X-Sequence-Number: 25059 A friend suggested that I use the Like predicate as part of my join condition and I was wondering if that was wise. For example, I have a column that describes the level of an event. There is A,B,C and then they can have children, such as AA,AB,BA,BB and they can all have children as well. So if I wanted to see all the children with their parents at every level it would be: select a.* from tbl1 a join tbl1 b on a.level like b.level || '%' That would give me on one side A and on the other side A,AA,AB,AAAB,... as well as AA and on the other side all of its children. I'm just nervous about using a Like in a join.