How To Use JOIN?

From: Takashi Tokunaga <taka-tok(at)chaos(dot)digital-magic(dot)co(dot)jp>
To: pgsql-sql(at)postgreSQL(dot)org
Subject: How To Use JOIN?
Date: 1998-11-17 16:05:45
Message-ID: 199811171611.BAA25713@yebisu2.digital-magic.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello PGSQL users, I'm having trobule using join statement:

I've created two tables and trying to compare contents of two
tables and receive results which found on two tables equaled.

------Here's what I did ------

1. I create two tables:

create table test1 (
name_1 varchar(10),
code_1 int
)\g

create table test2 (
name_2 varchar(10),
code_2 int
)\g

2. Entered sample data:

insert into test1 values ( '10', 1) \g
insert into test1 values ( '11', 2) \g

insert into test2 values ( '11', 1) \g
insert into test2 values ( '11', 2) \g

3. Now after that worked without any problem, so I now create SELECT
statement:

select * from test1 test2 where code_1 = test.code_2 \g
ERROR: attribute 'code_2' not found

nope that didn't work

select test1.name_1 from test1 test2 where test1.code_1 = test2.code_2 \g
ERROR: attribute 'code_2' not found

Umm... still no change.

------

Mmm... Any ideas?
If I can get value of test1.name_1 which also had equal value on code_1
and test2.code_2, I'll solve my trouble. It shouldn't be that complex but it's
been driving me nuts for few hours.

I'm using postgresql-6.3.2 under FreeBSD 2.2.6.

Thanx in Advance,

Takashi

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Herouth Maoz 1998-11-17 16:36:35 Re: [SQL] How To Use JOIN?
Previous Message pierre 1998-11-17 14:06:00 Blatant plug