Thread: LIKE query over multiple fields

LIKE query over multiple fields

From
Nathan Hand
Date:
I'm doing something like the following

   select * from mytable
     where field1 like '%pattern%' or field2 like '%pattern%';

I actually have 60+ fields so I found that the following was more
convenient even though it's not exactly the same.

   select * from mytable
     where (field1||field2) like '%pattern%';

My question is, can this be done in a cleaner way? Something that
works similarly to the first example by preference. I thought

   select * from mytable
     where * like '%pattern%';

Logically described what I wanted, but of course this didn't work
with postgresql (or any other xbase, as far as I can tell).

Please CC: responses to me, if that's convenient. I read the psql
mailing list via an archive which isn't always in sync.