Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Ross J. Reedstrom
On Fri, Aug 31, 2001 at 08:29:21AM -0700, Josh Berkus wrote: > > That's why we have the list. Personally, I'm still looking for a > comprehensive introductory SQL book to recommend. The ones I know are > either too simple and not that accurate (SQL for Dummies), proprietary > (MS SQL Server in

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Stephan Szabo
On Thu, 30 Aug 2001, Marc [iso-8859-1] André Paquin wrote: > Hello, > > 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 //

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Josh Berkus
Marc, > 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! Whenever you want to join to the

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Thomas Rehlich
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)

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Josh Berkus
Marc, > Yes, but I used this instead: > select dest.dest_name, air1.name as airport1, air2.name as airport2 > from > destination, airport air1, airport air2 where dest.airport_dep_id= > air1.airport_id and dest.airport_arr_id=air2.airport_id; > > This is very similar to your query... I think the

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Richard Poole
On Thu, Aug 30, 2001 at 04:25:41PM -0400, Marc André Paquin wrote: > Hello, > > 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

[SQL] Index Scan Backward vs. Sort/Sequential Scan when using ORDER BY

2001-08-31 Thread Keith Bussey
Greetings, I have stumbled upon a confusing aspect of PostgreSQL queries involving ORDER BY. In trying to figure out just why my ORDER BY queries were so slow, I came across something interesting. First, let me give you 2 very similar queries: 1) SELECT p.uid FROM client_profiles p

[SQL] 2 tables, joins and same name...

2001-08-31 Thread Marc André Paquin
Hello, 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 th

Re: [SQL] Help On Postgresql

2001-08-31 Thread Henshall, Stuart - WCP
a) Either of these should return the yaer (2001). See section 4.7 of the user guide SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40'); SELECT date_part('year', TIMESTAMP '2001-02-16 20:38:40'); b) The serial datatype will do this. It is actually just an int4 with a default value of nextva