Re: create constant values

Поиск
Список
Период
Сортировка
От Michael Glaesemann
Тема Re: create constant values
Дата
Msg-id 58DFC5B9-9A25-417F-AC82-F7C13C172AC1@seespotcode.net
обсуждение исходный текст
Ответ на Re: create constant values  (john@msasystems.net)
Список pgsql-novice
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)

Michael Glaesemann
grzm seespotcode net



В списке pgsql-novice по дате отправления:

Предыдущее
От: chrisj
Дата:
Сообщение: Re: [OT] Installing 8.3beta on debian (stable)
Следующее
От: Dean Rasheed
Дата:
Сообщение: A question of volatility