Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Conditional on ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 15529 of 17437
Post > Topic >>

Conditional on Select List

by fernando@[EMAIL PROTECTED] (Fernando) May 13, 2008 at 11:52 AM

This is a multi-part message in MIME format.
--------------080102090100020600040308
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Is it possible to do this?

SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table;

What I want is to return a boolean, but when I tried SELECT 
COUNT(colname)::BOOLEAN FROM table; it says it cannot cast bigint to 
boolean.

Is there such IF function or do I have to create my own.

Thank you.

--------------080102090100020600040308
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Comic Sans MS">Is it possible to do this?<br>
<br>
SELECT IF(COUNT(colname) &gt; 0, TRUE, FALSE) AS colname FROM table;<br>
<br>
What I want is to return a boolean, but when I tried SELECT
COUNT(colname)::BOOLEAN FROM table; it says it cannot cast bigint to
boolean.<br>
<br>
Is there such IF function or do I have to create my own.<br>
<br>
Thank you.<br>
</font>
</body>
</html>

--------------080102090100020600040308--
 




 7 Posts in Topic:
Conditional on Select List
fernando@[EMAIL PROTECTED  2008-05-13 11:52:24 
Re: Conditional on Select List
haraldarminmassa@[EMAIL P  2008-05-13 18:03:21 
Re: Conditional on Select List
sam@[EMAIL PROTECTED] (S  2008-05-13 17:04:17 
Re: Conditional on Select List
tgl@[EMAIL PROTECTED] (T  2008-05-13 12:07:37 
Re: Conditional on Select List
fernando@[EMAIL PROTECTED  2008-05-13 12:40:18 
Re: Conditional on Select List
doug@[EMAIL PROTECTED] (  2008-05-13 12:09:30 
Re: Conditional on Select List
richard.broersma@[EMAIL P  2008-05-13 09:10:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:11:47 CST 2008.