Re: JOIN and LIKE

From: Holger Klawitter <lists(at)klawitter(dot)de>
To: ktt <kestutis98(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: JOIN and LIKE
Date: 2002-07-16 07:56:34
Message-ID: 200207160956.34806.lists@klawitter.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Am Dienstag, 16. Juli 2002 09:10 schrieb ktt:
> hello,
>
> Could you provide me with some examples of using
> JOIN and LIKE in the same sentence?
> I woul like to join tables and search them for the
> text pattern.

You can use LIKE just like ;-) any other operator.

SELECT
*
FROM
a JOIN b ON a.id = b.id
WHERE
a.name LIKE 'pattern%'
;

There is no problem with using LIKE even in the
ON part of a join (at least in 7.2.1).

SELECT
*
FROM
a JOIN b ON a.data LIKE b.pattern
;

The full power of joins unfold when using LEFT JOIN
and such. In this case you might even get the pattern
which do not have something to match.

SELECT
*
FROM
a RIGHT JOIN b ON a.data LIKE b.pattern
;

Mit freundlichen Gruß
Holger Klawitter
--
Holger Klawitter http://www.klawitter.de
lists(at)klawitter(dot)de

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jd 2002-07-16 08:50:27 Re: Question: merit / feasibility of compressing frontend
Previous Message Henrik Steffen 2002-07-16 07:55:23 Re: Tom, I've got an emergency - please help me