Search Postgresql Archives

LIKE a set of pattern generated from a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux