Re: 'select where' using multiple columns.

From: Ian Johannesen <ij(at)perlpimp(dot)dk>
To: pgsql-sql(at)postgresql(dot)org
Cc: Rob Kirkbride <rob(at)rkcomputing(dot)co(dot)uk>
Subject: Re: 'select where' using multiple columns.
Date: 2005-08-05 10:24:19
Message-ID: 42F33E53.3000002@perlpimp.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi.

Rob Kirkbride wrote:
> I've googled around for this but can't see a decent way of doing this :
>
> I've got a persons name which is being stored say in 3 columns :-
> Title, Forename_1, Forename_2, Surname. I want to allow a search say for
> 'John Smith'. Problem is I can't just break it up into forename and
> surname because I won't also know.
> Is there a way to do something like a
> 'select * where forename_1,forename_2,surname like '%String%' ??
>
> Thanks for any help. Apologies if its a FAQ.

SELECT * FROM table WHERE forename_1 || ' ' || forename_2 || ' ' ||
surname LIKE '%String%';

--
Digitally Yours,

Ian Johannesen
web: http://perlpimp.dk/
msn: ij(at)perlpimp(dot)dk
cel: +45 31 13 73 76

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message daq 2005-08-05 10:37:52 Re: 'select where' using multiple columns.
Previous Message Rob Kirkbride 2005-08-05 09:46:45 'select where' using multiple columns.