pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Simple concatenation in select query
4+ messages / 4 participants
[nested] [flat]

* Simple concatenation in select query
@ 2000-07-31 19:48 Sandis <sandis@mediaparks.lv>
  2000-07-31 21:05 ` Re: Simple concatenation in select query Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Sandis @ 2000-07-31 19:48 UTC (permalink / raw)
  To: pgsql-sql

Hello,

Sorry for the stupid posting, but..

There was a string concatenation function in MySQL:
SELECT CONCAT(first_name, " ", last_name) FROM table;
Is there a similar function in Postgres?

Certainly, it's possible to live without it, but i'd like to write as above,
doing concatenation in place.

Ok, it seems i found it now:
SELECT TEXTCAT(first_name, last_name) FROM table;
but it allows only 2 arguments, inserting " " or ' ' (space) causes
an error: attribute ' ' not found! Why postgres doesnt see it as string?

Ok, i got it, after all! It took > 30 min to write this query.  :(
SELECT textcat(textcat(first_name,text ' '),last_name) from table;

It kind of strange, but i found this function not in "user manual",
but doing "\df text".. There is some differences between function
descriptions in manual and those that \df returns..
Virtually \df returns much more functions than in manual,
and there is some differences in argument types.

May be someone knows a better, complete manual with ALL
function described and code samples?

sandis@mediaparks.lv
www.mediaparks.lv





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

* Re: Simple concatenation in select query
  2000-07-31 19:48 Simple concatenation in select query Sandis <sandis@mediaparks.lv>
@ 2000-07-31 21:05 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2000-07-31 21:05 UTC (permalink / raw)
  To: Sandis <sandis@mediaparks.lv>; +Cc: pgsql-sql

"Sandis" <sandis@mediaparks.lv> writes:
> Ok, i got it, after all! It took > 30 min to write this query.  :(
> SELECT textcat(textcat(first_name,text ' '),last_name) from table;

It's a lot easier if you use the SQL-standard concatenation operator:

regression=# select 'foo' || 'bar';
 ?column?
----------
 foobar
(1 row)

textcat() just exists to implement the operator, which is why it's
not documented separately.

Dunno why you'd need to specify the type of the constant explicitly
in this context --- there is only one textcat function, so the system
ought to be able to figure it out.

			regards, tom lane



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

* RE: Simple concatenation in select query
@ 2000-07-31 21:05 Henry Lafleur <HLafleur@phoenixforge.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Henry Lafleur @ 2000-07-31 21:05 UTC (permalink / raw)
  To: Sandis <sandis@mediaparks.lv>; pgsql-sql

PostgreSQL has a string concatenation operator (see operators in the
manual):

SELECT last_name||', '||first_name FROM ...

Here's a ref: http://www.postgresql.org/docs/user/x2129.htm

Henry


-----Original Message-----
From: Sandis [mailto:sandis@mediaparks.lv]
Sent: Monday, July 31, 2000 2:48 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] Simple concatenation in select query


Hello,

Sorry for the stupid posting, but..

There was a string concatenation function in MySQL:
SELECT CONCAT(first_name, " ", last_name) FROM table;
Is there a similar function in Postgres?

Certainly, it's possible to live without it, but i'd like to write as above,
doing concatenation in place.

Ok, it seems i found it now:
SELECT TEXTCAT(first_name, last_name) FROM table;
but it allows only 2 arguments, inserting " " or ' ' (space) causes
an error: attribute ' ' not found! Why postgres doesnt see it as string?

Ok, i got it, after all! It took > 30 min to write this query.  :(
SELECT textcat(textcat(first_name,text ' '),last_name) from table;

It kind of strange, but i found this function not in "user manual",
but doing "\df text".. There is some differences between function
descriptions in manual and those that \df returns..
Virtually \df returns much more functions than in manual,
and there is some differences in argument types.

May be someone knows a better, complete manual with ALL
function described and code samples?

sandis@mediaparks.lv
www.mediaparks.lv




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

* Re: Simple concatenation in select query
@ 2003-09-20 17:05 yogesh selukar <yogesh_selukar@yahoo.com>
  0 siblings, 0 replies; 4+ messages in thread

From: yogesh selukar @ 2003-09-20 17:05 UTC (permalink / raw)
  To: pgsql-sql; sandis@mediaparks.lv

Hello Everybpdy,
     The concatination in select query u can write the query like this.
 
 select c.status||' this '||' is '||' the '||' status ' from course_master as c;
         This works fine
 
Regards
 
Yogesh


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

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


end of thread, other threads:[~2003-09-20 17:05 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-07-31 19:48 Simple concatenation in select query Sandis <sandis@mediaparks.lv>
2000-07-31 21:05 ` Tom Lane <tgl@sss.pgh.pa.us>
2000-07-31 21:05 RE: Simple concatenation in select query Henry Lafleur <HLafleur@phoenixforge.com>
2003-09-20 17:05 Re: Simple concatenation in select query yogesh selukar <yogesh_selukar@yahoo.com>

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