开发者

Compatible boolean data type of various relational databases

I am trying to create a select statement that is compatible with all major relational databases (MySQL, PostgreSQL, Derby, SQLite, ...).

Here the simple select statement: SELECT * FROM taggings WHERE public IS TRUE

The problem is that SQLite for example does not support the boolean data type, so I rewrote my statement to: SELECT 开发者_开发百科* FROM taggings WHERE public = 1

As far as I know it is valid for SQLite (wich uses some kind of byte for the public field) and also MySQL (which interprets the 1 as true, cause it uses the boolean type for the public field).

How about PostgreSQL when also uses a boolean public field? From the manual it looks like that I have to write SELECT * FROM taggings WHERE public = '1'. Or is that equivalent in that case to the above statement? (I don't have a chance to setup a PostgreSQL database here.)

Thanks for the help!


SELECT * FROM taggings WHERE public
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜