Skip site navigation (1) Skip section navigation (2)

Re: Proper SQL syntax requested

From: Richard Huxton <dev(at)archonet(dot)com>
To: blake(at)shopwhatcom(dot)com (Blake), pgsql-sql(at)postgresql(dot)org
Subject: Re: Proper SQL syntax requested
Date: 2004-04-27 12:06:42
Message-ID: 200404271306.42790.dev@archonet.com (view raw or flat)
Thread:
Lists: pgsql-sql
On Thursday 22 April 2004 00:41, Blake wrote:
>
> Select * from floors Where system = 1 ORDER by make
>
> This sorts by the Serial ID's in column make
>
> I would like to be able to sort by the actual Names associated back
> from the ID's. Anyway of doing this??

You don't say which table contains the name in question. Assuming we want 
column make_name from table make_description with an id of make_id then:

SELECT floors.* FROM floors, make_description 
WHERE system=1 AND floors.make = make_description.make_id
ORDER BY make_description.make_name;

This is called a join. Any book on databases/SQL should discuss this sort of 
stuff.

-- 
  Richard Huxton
  Archonet Ltd

In response to

pgsql-sql by date

Next:From: Richard HuxtonDate: 2004-04-27 12:09:55
Subject: Re: Customised Encoding
Previous:From: Achilleus MantziosDate: 2004-04-27 11:51:54
Subject: Re: How to get binary value for an Integer

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group