Saturday, January 28, 2012

Boolean column in where condition (SQL)

When we check a boolean value in condition, we can use this form.

select
* from SomeTable where true
.

Here true is a column with boolean data type. The above query will give all records which have true as the value for true column.

select * from SomeTable where not(true).

The above query will give all records in SomeTable where value for true column is false.

Most databases will accept this format.

No comments:

Post a Comment