I Want to write a sql query which will should always return false.
if i write
select 1 from dual where 1=2;
nothing is returned. how can i use where 1=2 which always returns "false".
That's because there is nothing where 1 = 2.
select false from dual
(Substitute the value you want it to return for false.)
Based on the plsql
and plsqldeveloper
tags I have to believe you're using Oracle. As it turns out there is no BOOLEAN type in the Oracle database product, although a BOOLEAN type does exist in PL/SQL. When I find a need to include a "true or false" value in the database I'll create a CHAR(1) column and constrain it to contain only values of 'T' or 'F'; thus, if 'F' is acceptable as a "false" value you could do something like:
SELECT 'F' FROM DUAL
If you don't like 'F' you can substitute any value you'd care to choose for the 'F'.
Share and enjoy.
SELECT CASE WHEN 1=2 THEN 1 ELSE 0 END FROM DUAL
Why don't you simply use
Select 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.