dbTalk Databases Forums  

array in postgre

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss array in postgre in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gavaneh
 
Posts: n/a

Default array in postgre - 07-08-2004 , 12:20 AM






Hi

suppose we have the following query:
select ....from ...where...and x *=3;

"x" is an integer array,here we want to check whether
"x" contains 3 or not,this is the same as one of
postgre documentaion example,however it doesnt
work.(why???)

should I set any option? any idea?

-thnx



__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #2  
Old   
Oliver Elphick
 
Posts: n/a

Default Re: array in postgre - 07-09-2004 , 03:41 AM






On Thu, 2004-07-08 at 06:20, gavaneh wrote:
Quote:
Hi

suppose we have the following query:
select ....from ...where...and x *=3;

"x" is an integer array,here we want to check whether
"x" contains 3 or not,this is the same as one of
postgre documentaion example,however it doesnt
work.(why???)

should I set any option? any idea?

From the documentation:
9.17.3. ANY/SOME (array)
expression operator ANY (array expression)
expression operator SOME (array expression)

The right-hand side is a parenthesized expression, which must
yield an array value. The left-hand expression is evaluated and
compared to each element of the array using the given operator,
which must yield a Boolean result. The result of ANY is "true"
if any true result is obtained. The result is "false" if no true
result is found (including the special case where the array has
zero elements).

SOME is a synonym for ANY

So in your case:
SELECT ... FROM .. WHERE ... 3 = ANY (x);


Oliver Elphick


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: array in postgre - 07-09-2004 , 11:29 PM



gavaneh <gavaneh (AT) yahoo (DOT) com> writes:
Quote:
suppose we have the following query:
select ....from ...where...and x *=3;
"x" is an integer array,here we want to check whether
"x" contains 3 or not,this is the same as one of
postgre documentaion example,however it doesnt
work.(why???)
Probably because you didn't install the contrib module that supports
the *= operator.

Note that as of 7.4 there is a more standard way to do this.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.