pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed'select where' using multiple columns.
5+ messages / 4 participants
[nested] [flat]
* 'select where' using multiple columns.
@ 2005-08-05 09:46 Rob Kirkbride <rob@rkcomputing.co.uk>
0 siblings, 3 replies; 5+ messages in thread
From: Rob Kirkbride @ 2005-08-05 09:46 UTC (permalink / raw)
To: pgsql-sql
Hi,
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.
Rob
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'select where' using multiple columns.
@ 2005-08-05 10:24 Ian Johannesen <ij@perlpimp.dk>
parent: Rob Kirkbride <rob@rkcomputing.co.uk>
2 siblings, 1 reply; 5+ messages in thread
From: Ian Johannesen @ 2005-08-05 10:24 UTC (permalink / raw)
To: pgsql-sql; +Cc: Rob Kirkbride <rob@rkcomputing.co.uk>
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@perlpimp.dk
cel: +45 31 13 73 76
Attachments:
smime.p7s (application/x-pkcs7-signature, 3.2K) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'select where' using multiple columns.
@ 2005-08-05 10:37 daq <daq@ugyvitelszolgaltato.hu>
parent: Rob Kirkbride <rob@rkcomputing.co.uk>
2 siblings, 0 replies; 5+ messages in thread
From: daq @ 2005-08-05 10:37 UTC (permalink / raw)
To: Rob Kirkbride <rob@rkcomputing.co.uk>; +Cc: pgsql-sql
RK> Hi,
RK> I've googled around for this but can't see a decent way of doing this :
RK> I've got a persons name which is being stored say in 3 columns :-
RK> Title, Forename_1, Forename_2, Surname. I want to allow a search say for
RK> 'John Smith'. Problem is I can't just break it up into forename and
RK> surname because I won't also know.
RK> Is there a way to do something like a
RK> 'select * where forename_1,forename_2,surname like '%String%' ??
RK> Thanks for any help. Apologies if its a FAQ.
RK> Rob
RK> ---------------------------(end of broadcast)---------------------------
RK> TIP 5: don't forget to increase your free space map settings
Try this way:
select * .... where forename_1||' '||forename_2||' '||surname like '%String%'
or
select * .... where forename_1||' '||forename_2||' '||surname~'String'
DAQ
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'select where' using multiple columns.
@ 2005-08-05 10:43 Hélder M. Vieira <hmv@mail.telepac.pt>
parent: Rob Kirkbride <rob@rkcomputing.co.uk>
2 siblings, 0 replies; 5+ messages in thread
From: Hélder M. Vieira @ 2005-08-05 10:43 UTC (permalink / raw)
To: pgsql-sql
> Is there a way to do something like a
> 'select * where forename_1,forename_2,surname like '%String%' ??
You could try the following, but it won't get a medal for performance...
SELECT * FROM xpto WHERE forename_1 LIKE '%String%' OR forename_2 LIKE
'%String%' OR surname LIKE '%String%'
Helder M. Vieira
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: 'select where' using multiple columns.
@ 2005-08-05 10:49 Rob Kirkbride <rob@rkcomputing.co.uk>
parent: Ian Johannesen <ij@perlpimp.dk>
0 siblings, 0 replies; 5+ messages in thread
From: Rob Kirkbride @ 2005-08-05 10:49 UTC (permalink / raw)
To: ij@perlpimp.dk; +Cc: pgsql-sql
Ian Johannesen wrote:
>Hi.
>
>Rob Kirkbride wrote:
>
>
>>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%' ??
>>
>>
>>
>SELECT * FROM table WHERE forename_1 || ' ' || forename_2 || ' ' ||
>surname LIKE '%String%';
>
>
>
Thanks for the quick response. I've tried that and it works fine. Thanks
a lot and thanks to Daq and Helder.
Rob
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-08-05 10:49 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-05 09:46 'select where' using multiple columns. Rob Kirkbride <rob@rkcomputing.co.uk>
2005-08-05 10:24 ` Ian Johannesen <ij@perlpimp.dk>
2005-08-05 10:49 ` Rob Kirkbride <rob@rkcomputing.co.uk>
2005-08-05 10:37 ` daq <daq@ugyvitelszolgaltato.hu>
2005-08-05 10:43 ` Hélder M. Vieira <hmv@mail.telepac.pt>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox