Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f7VG2Of55165 for ; Fri, 31 Aug 2001 12:02:24 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f7VFk6H73079 for pgsql-sql@postgresql.org; Fri, 31 Aug 2001 11:46:06 -0400 (EDT) (envelope-from news) From: Thomas Rehlich X-Newsgroups: comp.databases.postgresql.sql Subject: Re: 2 tables, joins and same name... Date: Fri, 31 Aug 2001 17:55:15 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 41 Message-ID: <3B8FB363.1000509@wtal.de> References: <3B8EA145.1E9349F3@inter-resa.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: scrappy@hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801 X-Accept-Language: en-us, de To: pgsql-sql@postgresql.org X-Archive-Number: 200108/381 X-Sequence-Number: 4640 Marc André Paquin wrote: > Here is 2 tables: > > airport > --------- > airport_id > name > code > city_id > > destination > ----------- > destination_id > dest_name > ... > airport_dep_id // using airport.airport_id (departure) > airport_arr_id // using airport.airport_id has well (arrival) > > I have 2 columns in the second table that uses the same name column in > the first table... > > I dont know how to formulate my SQL query... I want to select the > destinations in the destination table with not the ID of each airport > but their names. I can do a join with one but with the second one, I > get no results... And this is confusing! May be I'm wrong, but I think you mean something like this one select dest_name , air1.name as airport1 , air2.name as airport2 from destination join airport as air1 on air1.airport_id = destination.airport_dep_id join airport as air2 on air2.airport_id = destination.airport_arr_id Thomas