Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Share your agentic AI experience, learn from others, and earn a new badge: Put Agentic AI to Work
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

where 1=1?

I have seen that some people write

"select

     lastname

     firstname

from

     customer

where 1=1"

The purpose of haveing "where 1=1"? What result would it gain?

Labels (1)
4 Replies
Not applicable
Author

I believe this is used to generate a permanently 'true' boolean statement,  perhaps to force that a database to return a resulset. However this shouldn't be necessary unless the database from which you are getting data is buggy, and doesn't return data sometimes, using a statement that forces a "true" on the query, may get the job done.

best

rwunderlich
MVP
MVP

As Jorge indicated, it's an "always true" clause. It logically has the same effect as no where clause. I've seen two uses in QV script.

1. As a placeholder, commonly used when variables are used to generate the SQL statement. The WHERE is a fixed bit of text and the 1=1 avoids a syntax error when you want no clause.

2. As a way to force an unoptimized load from a QVD. In that case you would see it in a LOAD statement rather than a SQL SELECT.

-Rob

Debbie_P
Employee
Employee

what is the reason to force an unoptimized load?

rwunderlich
MVP
MVP

A few items don't work as optimized loads. For example, mapping table loads.  Can't recall others at the moment.

-Rob

http://masterssummit.com

http://qlikviewcookbook.com