Am 23.07.2014 um 23:58 schrieb Heiko Schlittermann: > Andreas Kretschmer <andr...@a-kretschmer.de> (Mi 23 Jul 2014 23:50:53 CEST): >> >> >> Mir scheint, Du suchst sowas wie: >> >> test=# create type colors as enum ('red','green', 'blue'); >> CREATE TYPE >> test=*# create table foobar (id int, color colors[]); >> CREATE TABLE >> test=*# insert into foobar values (1, array['red'::colors, 'blue'::colors]); >> INSERT 0 1 >> test=*# select * from foobar; >> id | color >> ----+------------ >> 1 | {red,blue} >> (1 row) >> test=*# select id, array_to_string(color,',') as color from foobar; >> id | color >> ----+---------- >> 1 | red,blue >> (1 row) >> >> >> >> Also, erst einmal den Typ als ENUM und davon dann ein ARRAY. > > > Weil das so etwas schöner aussähe: > > SELECT name FROM items WHERE colors CONTAINS 'red'; > > Wie in der anderen Antwort beschrieben, wird es wohl tatsächlich die > normalisierte Darstellung werden, und keine Arrays.
Kannst Dir ja ungefähr so etwas SELECT i.name, io.color, io.size FROM item as i, item_options as io WHERE i.id = io.item_id in eine View packen. Dann kannst Du wie oben drauf zugreifen. Jetzt wahrscheinlich nicht das schnellste was wo geht, aber wat solls ;D Gruß Frank
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Lug-dd maillist - Lug-dd@mailman.schlittermann.de https://ssl.schlittermann.de/mailman/listinfo/lug-dd