Re: JOIN and LIKE

Поиск
Список
Период
Сортировка
От Holger Klawitter
Тема Re: JOIN and LIKE
Дата
Msg-id 200207160956.34806.lists@klawitter.de
обсуждение исходный текст
Ответ на JOIN and LIKE  (ktt <kestutis98@yahoo.com>)
Список 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@klawitter.de

В списке pgsql-general по дате отправления:

Предыдущее
От: "Henrik Steffen"
Дата:
Сообщение: Re: Tom, I've got an emergency - please help me
Следующее
От: Michael Meskes
Дата:
Сообщение: Re: Embedded SQL in a function