From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
---|---|
To: | john(at)msasystems(dot)net |
Cc: | pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: create constant values |
Date: | 2007-11-23 21:19:21 |
Message-ID: | 58DFC5B9-9A25-417F-AC82-F7C13C172AC1@seespotcode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Nov 21, 2007, at 13:16 , john(at)msasystems(dot)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)
Michael Glaesemann
grzm seespotcode net
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Rasheed | 2007-11-24 13:00:03 | A question of volatility |
Previous Message | chrisj | 2007-11-23 19:13:50 | Re: [OT] Installing 8.3beta on debian (stable) |