Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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?

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
Partner Ambassador/MVP
Partner Ambassador/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

dyy
Employee
Employee

what is the reason to force an unoptimized load?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/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