Обсуждение: JOIN and LIKE

Поиск
Список
Период
Сортировка

JOIN and LIKE

От
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.

ktt

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

Re: JOIN and LIKE

От
Holger Klawitter
Дата:
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