pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
select a part of a name
7+ messages / 7 participants
[nested] [flat]

* select a part of a name
@ 1999-12-08 08:12  Fred Schoonewille <schoonewille@coh.fgg.eur.nl>
  0 siblings, 1 reply; 7+ messages in thread

From: Fred Schoonewille @ 1999-12-08 08:12 UTC (permalink / raw)
  To: pgsql-sql@hub.org <pgsql-sql@hub.org>

Hi,

I am trying to select a part of a name from the columm NAME,

e.g. sql asks the user for input like:   jone

sql should give all names which begin with or containing 'jone'

-jones
-Tom-Jones

Working with:

select * from TEST
where NAME= '&name'

finds only exact matches

Can I use e.g.  %    ?
--

-----------------------------------
Fred Schoonewille

Applicatiebeheer
Computer Ondersteuning Hoboken
-----------------------------------
http://www.eur.nl/fgg/coh
-------------------------------------------------------







^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [SQL] select a part of a name
@ 1999-12-08 08:40  Vladimir Terziev <vlady@school.digsys.bg>
  parent: Fred Schoonewille <schoonewille@coh.fgg.eur.nl>
  0 siblings, 1 reply; 7+ messages in thread

From: Vladimir Terziev @ 1999-12-08 08:40 UTC (permalink / raw)
  To: Fred Schoonewille <schoonewille@coh.fgg.eur.nl>; +Cc: pgsql-sql@hub.org <pgsql-sql@hub.org>



        You must write:

        select * from TEST where name ~ '&name';

        This will match all names containing &name


		Vladimir



On Wed, 8 Dec 1999, Fred Schoonewille wrote:

> Hi,
> 
> I am trying to select a part of a name from the columm NAME,
> 
> e.g. sql asks the user for input like:   jone
> 
> sql should give all names which begin with or containing 'jone'
> 
> -jones
> -Tom-Jones
> 
> Working with:
> 
> select * from TEST
> where NAME= '&name'
> 
> finds only exact matches
> 
> Can I use e.g.  %    ?
> --
> 
> -----------------------------------
> Fred Schoonewille
> 
> Applicatiebeheer
> Computer Ondersteuning Hoboken
> -----------------------------------
> http://www.eur.nl/fgg/coh
> -------------------------------------------------------
> 
> 
> 
> 
> 
> ************
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: [SQL] select a part of a name
@ 1999-12-08 14:49  Justin Long <justinlong@strategicnetwork.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Justin Long @ 1999-12-08 14:49 UTC (permalink / raw)
  To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

unsubscribe



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [SQL] select a part of a name
@ 1999-12-08 15:47  kaiq@realtyideas.com
  parent: Vladimir Terziev <vlady@school.digsys.bg>
  0 siblings, 1 reply; 7+ messages in thread

From: kaiq@realtyideas.com @ 1999-12-08 15:47 UTC (permalink / raw)
  To: Vladimir Terziev <vlady@school.digsys.bg>; +Cc: Fred Schoonewille <schoonewille@coh.fgg.eur.nl>; pgsql-sql@hub.org <pgsql-sql@hub.org>

use: where name like '%names%' 

On Wed, 8 Dec 1999, Vladimir Terziev wrote:

> 
> 
>         You must write:
> 
>         select * from TEST where name ~ '&name';
> 
>         This will match all names containing &name
> 
> 
> 		Vladimir
> 
> 
> 
> On Wed, 8 Dec 1999, Fred Schoonewille wrote:
> 
> > Hi,
> > 
> > I am trying to select a part of a name from the columm NAME,
> > 
> > e.g. sql asks the user for input like:   jone
> > 
> > sql should give all names which begin with or containing 'jone'
> > 
> > -jones
> > -Tom-Jones
> > 
> > Working with:
> > 
> > select * from TEST
> > where NAME= '&name'
> > 
> > finds only exact matches
> > 
> > Can I use e.g.  %    ?
> > --
> > 
> > -----------------------------------
> > Fred Schoonewille
> > 
> > Applicatiebeheer
> > Computer Ondersteuning Hoboken
> > -----------------------------------
> > http://www.eur.nl/fgg/coh
> > -------------------------------------------------------
> > 
> > 
> > 
> > 
> > 
> > ************
> > 
> > 
> 
> 
> ************
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [SQL] select a part of a name
@ 1999-12-08 16:50  Moray McConnachie <moray.mcconnachie@computing-services.oxford.ac.uk>
  parent: kaiq@realtyideas.com
  0 siblings, 1 reply; 7+ messages in thread

From: Moray McConnachie @ 1999-12-08 16:50 UTC (permalink / raw)
  To: kaiq@realtyideas.com; Vladimir Terziev <vlady@school.digsys.bg>; +Cc: Fred Schoonewille <schoonewille@coh.fgg.eur.nl>; pgsql-sql@hub.org



> use: where name like '%names%'

Except that the user specified he wanted to be able to find Tom Jones
and jonas from the search text jon, so you either need to use:

where lower(name) like ('%' ¦¦ lower(searchtext) ¦¦ '%')

or something similar, which is slow unless you have an index on
lower(name), and even then.
Or you use the regexp search ~* given previously.

----------------------------------------------------------------------
----------------
Moray.McConnachie@computing-services.oxford.ac.uk





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [SQL] select a part of a name
@ 1999-12-09 02:36  neko@kredit.sth.szif.hu
  parent: Moray McConnachie <moray.mcconnachie@computing-services.oxford.ac.uk>
  0 siblings, 1 reply; 7+ messages in thread

From: neko@kredit.sth.szif.hu @ 1999-12-09 02:36 UTC (permalink / raw)
  To: pgsql-sql@hub.org

On Wed, 8 Dec 1999, Moray McConnachie wrote:
> 
> > use: where name like '%names%'
> 
> Except that the user specified he wanted to be able to find Tom Jones
> and jonas from the search text jon, so you either need to use:
> 
> where lower(name) like ('%' ŚŚ lower(searchtext) ŚŚ '%')

> or something similar, which is slow unless you have an index on
> lower(name), and even then.
I think, this case always will be slow. Because the first '%'. I'm not
sure about all of access methods, and comparsion operators. But this
combination of them (btree/hash -- like) can't do indexed substr lookup.
Is there any tricks, to do it?

--
 nek;(




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [SQL] select a part of a name
@ 1999-12-09 08:57  tjk@tksoft.com <tjk@tksoft.com>
  parent: neko@kredit.sth.szif.hu
  0 siblings, 0 replies; 7+ messages in thread

From: tjk@tksoft.com @ 1999-12-09 08:57 UTC (permalink / raw)
  To: neko@kredit.sth.szif.hu; +Cc: pgsql-sql@hub.org

I am just an observer here, but in my understanding,
it is impossible to create an index for this type of case,
and take advantage of it, because the index would have to
be on the partial string "jon" inside the words "Tom Jones"
and "jonas."

I.e. you have to do a sequential scan of all records to find
your matches. Speed of the query, therefore, is only influenced
by the comparison speed. Is a regex search faster, or is
a LIKE search faster? My guess is that a regex search such as 
~* 'jon' would be the fastest because it proceeds through the 
string one character at a time, and doesn't need to convert the 
text to lower case first, like a LIKE search will have to. 
This depends on the regex implementation in postgres, of course.
In any case, the difference should be insignificant. I would 
use the method you find more convenient. 

Troy

> 
> On Wed, 8 Dec 1999, Moray McConnachie wrote:
> > 
> > > use: where name like '%names%'
> > 
> > Except that the user specified he wanted to be able to find Tom Jones
> > and jonas from the search text jon, so you either need to use:
> > 
> > where lower(name) like ('%' ¦¦ lower(searchtext) ¦¦ '%')
> 
> > or something similar, which is slow unless you have an index on
> > lower(name), and even then.
> I think, this case always will be slow. Because the first '%'. I'm not
> sure about all of access methods, and comparsion operators. But this
> combination of them (btree/hash -- like) can't do indexed substr lookup.
> Is there any tricks, to do it?
> 
> --
>  nek;(
> 
> 
> ************
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~1999-12-09 08:57 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-08 08:12 select a part of a name Fred Schoonewille <schoonewille@coh.fgg.eur.nl>
1999-12-08 08:40 ` Vladimir Terziev <vlady@school.digsys.bg>
1999-12-08 15:47   ` kaiq@realtyideas.com
1999-12-08 16:50     ` Moray McConnachie <moray.mcconnachie@computing-services.oxford.ac.uk>
1999-12-09 02:36       ` neko@kredit.sth.szif.hu
1999-12-09 08:57         ` tjk@tksoft.com <tjk@tksoft.com>
1999-12-08 14:49 RE: [SQL] select a part of a name Justin Long <justinlong@strategicnetwork.org>

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