need a query

Started by AI Rummanabout 16 years ago4 messagesgeneral
Jump to latest
#1AI Rumman
rummandba@gmail.com

I need a query to get the initial letter of the words:
Like:

Ispahani Public School -------- IPS
Ahmed Iftekhar -------- AI
Any help please.

#2Florent THOMAS
mailinglist@tdeo.fr
In reply to: AI Rumman (#1)
Re: need a query

and what abourt that :
http://www.postgresql.org/docs/8.4/interactive/functions-string.html

Le lundi 29 mars 2010 à 14:44 +0600, AI Rumman a écrit :

Show quoted text

I need a query to get the initial letter of the words:
Like:

Ispahani Public School -------- IPS
Ahmed Iftekhar -------- AI

Any help please.

#3Timo Klecker
klecker@decoit.de
In reply to: AI Rumman (#1)
Re: need a query

Try this:

SELECT regexp_matches('foobar beque bazil barf bonk', '(\\m.)', 'g')

Now you have the first letters, you can use array_to_string to get an string
and use concat_str after this:

http://stackoverflow.com/questions/43870/how-to-concatenate-strings-of-a-str
ing-field-in-a-postgresql-group-by-query

Mit freundlichen Grüßen

Timo Klecker

Von: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] Im Auftrag von AI Rumman
Gesendet: Montag, 29. März 2010 10:45
An: pgsql-general General
Betreff: [GENERAL] need a query

I need a query to get the initial letter of the words:
Like:

Ispahani Public School -------- IPS
Ahmed Iftekhar -------- AI

Any help please.

#4Ognjen Blagojevic
ognjen@etf.bg.ac.rs
In reply to: Timo Klecker (#3)
Re: need a query

If you are sure that your words are space delimited, you may use this:

select regexp_replace('Ispahani Public School'||' ', '([^ ])([^ ]* )',
'\\1', 'g');

Regards,
Ognjen

Timo Klecker wrote:

Show quoted text

Try this:

SELECT regexp_matches('foobar beque bazil barf bonk', '(\\m.)', 'g')

Now you have the first letters, you can use array_to_string to get an
string and use concat_str after this:

http://stackoverflow.com/questions/43870/how-to-concatenate-strings-of-a-string-field-in-a-postgresql-group-by-query

Mit freundlichen Gr��en

Timo Klecker

* *

* *

*Von:* pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] *Im Auftrag von *AI Rumman
*Gesendet:* Montag, 29. M�rz 2010 10:45
*An:* pgsql-general General
*Betreff:* [GENERAL] need a query

I need a query to get the initial letter of the words:
Like:

Ispahani Public School -------- IPS
Ahmed Iftekhar -------- AI

Any help please.