Hello
I have frequently encountered the need of combining two tables into one.
First, please take a look at the following table setups...
CREATE TABLE topics (
id SERIAL PRIMARY KEY,
topic TEXT NOT NULL
);
CREATE TABLE messages (
id SERIAL PRIMARY KEY,
topic INTEGER REFERENCES
On Friday 22 May 2009 6:48:43 am Richard Ekblom wrote:
Hello
I have frequently encountered the need of combining two tables into one.
First, please take a look at the following table setups...
CREATE TABLE topics (
id SERIAL PRIMARY KEY,
topic TEXT NOT NULL
);
CREATE TABLE
-sql@postgresql.org
Sent: Friday, May 22, 2009 3:47 PM
Subject: Re: [SQL] Need help combining 2 tables together
Dear Richard Ekblom,
I think Mr. Adrian Klaver gave you the solution. Mine is the similar
solution
SELECT message.id,topic.topic,message.message
if you want topics listed which don't yet have messages try
select t.id, t.topic, m.id, m.message from topics t left join messages m on
m.topic = t.id;
On Fri, May 22, 2009 at 8:47 AM, James Kitambara jameskitamb...@yahoo.co.uk
wrote:
Dear Richard Ekblom,
I think Mr. Adrian Klaver gave you