dbTalk Databases Forums  

INT as BOOLEAN

comp.databases.postgresql comp.databases.postgresql


Discuss INT as BOOLEAN in the comp.databases.postgresql forum.



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

Default INT as BOOLEAN - 07-18-2009 , 08:52 AM






Hello,

I really just want to know specifically whether

SELECT * FROM test WHERE boolean_column;
SELECT * FROM test WHERE integer_column;

work or not.

Can anyone please run this on some test table, please? I don't want to
download, install, and uninstall PostgreSQL only for running a single
statement.

TIA
Karsten

Reply With Quote
  #2  
Old   
Karsten Wutzke
 
Posts: n/a

Default Re: INT as BOOLEAN - 07-18-2009 , 09:38 AM






On 18 Jul., 15:52, Karsten Wutzke <kwut... (AT) web (DOT) de> wrote:
Quote:
Hello,

I really just want to know specifically whether

SELECT * FROM test WHERE boolean_column;
The above obviously works:
http://www.postgresql.org/docs/8.1/s...e-boolean.html

This is not surprising.

Can anyone please run

SELECT * FROM test WHERE integer_column;

please?

Karsten

Reply With Quote
  #3  
Old   
Jens Henrik Leonhard Jensen
 
Posts: n/a

Default Re: INT as BOOLEAN - 07-18-2009 , 05:29 PM



Karsten Wutzke wrote:
Quote:
Can anyone please run

SELECT * FROM test WHERE integer_column;

please?

Karsten
No i do not work.
But you can do

SELECT * FROM test WHERE bool(integer_column);

/Jens Henrik

Reply With Quote
  #4  
Old   
Coniglio Sgabbiato
 
Posts: n/a

Default Re: INT as BOOLEAN - 07-24-2009 , 06:34 AM



Karsten Wutzke ha scritto:
Quote:
On 18 Jul., 15:52, Karsten Wutzke <kwut... (AT) web (DOT) de> wrote:
Hello,

I really just want to know specifically whether

SELECT * FROM test WHERE boolean_column;

The above obviously works:
http://www.postgresql.org/docs/8.1/s...e-boolean.html

This is not surprising.

Can anyone please run

SELECT * FROM test WHERE integer_column;

please?

Karsten
db_atm=# create table test(b bool, i int);
CREATE TABLE
db_atm=# insert into test (b, i) values (true, 1);
INSERT 0 1
db_atm=# insert into test (b, i) values (true, 2);
INSERT 0 1
db_atm=# insert into test (b, i) values (true, 0);
INSERT 0 1
db_atm=# select * from test where b;
b | i
---+---
t | 1
t | 2
t | 0
(3 rows)

db_atm=# select * from test where i;
ERROR: argument of WHERE must be type boolean, not type integer
db_atm=# select * from test where i::bool;
b | i
---+---
t | 1
t | 2
(2 rows)

db_atm=# drop table test;
DROP TABLE
db_atm=#

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.