Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats meaning of where false; in SQL query

I came across one SQL query in sqitch db schema management tool which is as follows:

BEGIN;

select subject , comment , timestamp
from tutorial.video
where false; 

ROLLBACK;

Above query is part of verify strategy; What is interpretation or application of where false; in above query?

like image 458
Pramod S. Nikam Avatar asked Sep 13 '25 21:09

Pramod S. Nikam


2 Answers

It is a where condition to be used when the query should not return any result. Some DBMS supporting boolean values, Postgres for example, works with that instead of the classic where 1=1.

Basically, where false is the same as where 1=0.

like image 81
P3trur0 Avatar answered Sep 16 '25 11:09

P3trur0


As far as I can tell it's to make you always get back 0 results. Same as doing something like where 1=0

like image 36
Roee N Avatar answered Sep 16 '25 12:09

Roee N