Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concatenate strings

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
AU
Hi there,
if i have a query which is the following:
select '<option value=' || id || '>' || name as hehe from library;

which produces the result
hehe
------------------------------------------------------
<option value=1>Bayside City Council Library Service


How can i make it concatenate every record which is in that table and return it as one field?

Is there a standard function for something like this or has anyone written something similiar?

Thanks in Advance


troy
 
You can use any delimeter to seperate that records, Just for example what i have used is ; (semicolon) as a delimiter for records, and you can extract the records using front end login by looking for semicolons, or if you wish to store semicolon as a part of record then you may choose any special charector or extended ascii charectors for that, through front end.
 
sorry i didn't make myself clear
if i had in the database

id | url
----+-------------------------------
1 | 2 |
i would do
select '<option value=' || id || '>' || name as hehe from library;

which produces the result
hehe
------------------------------------------------------
<option value=1> <option value=2>
which returns 2 records. What i'm looking for is a way to make it so it returns the whole thing in one field. Therefore when i use my scripting language (perl) i can just fetch the one record which would have all the data in it. I hope this makes more sense..

cheers

troy
 
Then for the multiple records value, you should choose temp tables, You should select all the records in to one temp table using &quot;create temp table tmptable as select * from table&quot;
then select the records using &quot;select * from tmptable&quot;
this will solve your problem.



Rahul Gade
( Concretio India Pvt.Ltd., Nagpur, India)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top