Skip site navigation (1) Skip section navigation (2)

put text list into table form

From: "Web2cad" <alex(at)web2cad(dot)co(dot)jp>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: put text list into table form
Date: 2006-01-26 02:23:51
Message-ID: 001801c6221f$8bd39e30$7dfda8c0@hpxw4100 (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I have a list of cities stored in flat file that I would like to left join with another table.

The file looks like this:

I want to put them into a table like this:

I don't actually want to store them into the data base. I just want to get the above table with a select statement.

At the moment I'm using this statement which I feel is rather ugly:
select 'city1' union select 'city2' union select 'city3'

Is there a way of putting a text list into table form without using a bunch of unions? Like a row separator  (RS)?
So I can do something like 
select 'city1'(RS)'city2'(RS)'city3'

Thanks for any help


pgsql-novice by date

Next:From: RobDate: 2006-01-26 18:25:14
Subject: Charting postgres schemas and table data into Kivio
Previous:From: Jaime CasanovaDate: 2006-01-25 22:02:56
Subject: Re: block transactions in stored procedures

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group