Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [NOVICE] create constant values

From: Michael Glaesemann <grzm(at)seespotcode.net>
Date: Fri Nov 23 2007 - 16:19:21 EST

On Nov 21, 2007, at 13:16 , john@msasystems.net wrote:

> Hi,
>
> i have a:
> select * from foo where type = 1 and score > 12;
>
> i would like to say
>
> select * from foo where type = QUARTERBACK and
> score > 12;

You should have a table which enumerates your types, so you can do something like:

SELECT *
   FROM foo
   JOIN foo_types USING (type)
   WHERE foo_types.type = 'quarterback'

       AND score > 12;

Magic numbers in a database (or anywhere else for that matter) is not a good idea.

(Or use the enum types in 8.3, currently beta3)

Do you need help?X

Michael Glaesemann
grzm seespotcode net

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly
Received on Fri Nov 23 16:19:51 2007

This archive was generated by hypermail 2.1.8 : Thu Jun 19 2008 - 00:04:14 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library