LIKE a set of pattern generated from a table

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема LIKE a set of pattern generated from a table
Дата
Msg-id 20100209180125.3ef2047a@dawn.webthatworks.it
обсуждение исходный текст
Список pgsql-general
I've a column that contain something formed by concatenating fields
from another table

create table stuff(
 glued varchar(30),
  ...
);

insert into stuff select 'constA,' || field1 || ',' || field2 from
origin where ...;

insert into stuff select 'constB,' || field1 || ',' || field2 from
origin where ...;

I know this is terrible... but this is what I have, and I can't
change it.

Now what I'd like to do is selecting in stuff using a pattern as:

select * from stuff where glue like (
  select '%,' || field1 || ',' || field2 || '%'
    from origin
    where ...
);

But this isn't going to work.
Any other way other than specifying all the const one by one in a
union and then look for equality?

select * from stuff where glue in (
 select 'constA,' || field1 || ',' || field2 from
   origin where ...
 union
 select 'constB,' || field1 || ',' || field2 from
   origin where ...
);

--
Ivan Sergio Borgonovo
http://www.webthatworks.it


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

Предыдущее
От: Boszormenyi Zoltan
Дата:
Сообщение: Re: ERROR: could not load library "...": Exec format error
Следующее
От: Seb
Дата:
Сообщение: SSL connection lost after long-lasting copy command