Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER 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

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

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