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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to solve this problem?

Status
Not open for further replies.

msc27jxg

Programmer
Jul 13, 2003
1
GB
These are my PostgreSQL tables:

pid | name
1 | A
2 | B
3 | C
4 | D
5 | E

tid | pid 1 | pid 2 | pid 3
1 | 1 | 2 | 3

Bascially, I would like to write a query to list only
the names which their "pid" match those pids in the
other table. If anyone knows, pls help!!

Many Thanks!!

Joe
 
with this schema (let's name the first table t1, and the second t2)

SELECT t11 AS name1, t12 AS name2, t13 AS name3 FROM t2 AS t2, t1 AS t11, t1 AS t12, t1 AS t13 WHERE t2.pid1 = t11.pid AND t2.pid2 = t12.pid AND t2.pid3 = t13.pid;

I hope it's clear (and I've understood what's needed)

I think that is is possible that is not the best schema possible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top