Re: [GENERAL] questing using array
От | Peter Eisentraut |
---|---|
Тема | Re: [GENERAL] questing using array |
Дата | |
Msg-id | Pine.LNX.4.10.9910132203430.2573-100000@peter-e.yi.org обсуждение исходный текст |
Ответ на | questing using array (Kevin Heflin <kheflin@shreve.net>) |
Список | pgsql-general |
You might want to look into the contrib/array directory which has _some_ helpers with arrays. But in general, using arrays in cases like yours is a bad idea because, a) It has nothing to do with relational database design b) Arrays were not designed for this kind of stuff, so you won't get very far. Regarding a), redesign your table like this name varchar(20) ageid int4 and make the records like this: test 1 test 2 test 3 test 4 and then you can use a simple select to find your answer. (Yes, this looks like you're storing more data, but that is how things are supposed to work.) Regarding b), arrays were created mostly for geometric objects. Of course you still could ask questions like "give me a polygon that has some coordinate that has a 20 in it", but it's unlikely and specialty functions exist to deal with questions you would usually have. -Peter On Oct 12, Kevin Heflin mentioned: > > Just trying to get a handle on how to work with an array as a datatype. > > For exampel I set up a table: > > name varchar (20), > ageids int4[] > > > Made an INSERT like: > > insert into TABLENAME (name, ageids) values ('test', '{1, 2, 3, 4}'); > > > What I haven't been able to figure out is how to do a select where one of > the ageids = a particular number. > > > I'd like to do something like > select * from tablename where ( any ageids = 3 ) > > just don't know the syntax.. if this is even possible. Any suggestions > would be appreciated. -- Peter Eisentraut Sernanders vaeg 10:115 peter_e@gmx.net 75262 Uppsala http://yi.org/peter-e/ Sweden
В списке pgsql-general по дате отправления: