Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I found this code that I can't 2

Status
Not open for further replies.

mimi2

Technical User
Joined
Apr 2, 2002
Messages
407
Location
CA
Hi, I found this code that I can't understand
<cfquery name=&quot;qGetBid&quot; datasource=&quot;#application.ds#&quot;>
select id from billing where
0 = 0
<cfloop list=&quot;#dbfields#&quot; index=&quot;i&quot;>
<cfif len(evaluate(i))>
and #i# = '#evaluate(i)#'
</cfif>
</cfloop>
</cfquery>

What's this &quot;0 = 0&quot; ?
Thanks
 
Setting a WHERE attribute such as 0=0 insures your query will return every record in the database. Mitch Duszynski
Web Developer
Human Kinetics
PO Box 5076, Champaign, IL 61825
Tel: 217-351-5076 x2474 | Fax: 217-351-2674
mitchd@hkusa.com |
 
This is a very common thing when using dynamic queries. Heres why:

You can have multiple 'AND' condition statements, but only ONE 'WHERE' clause. People can 'use up' the WHERE clause with 0=0 (always true) and then use dynamic looping to always check 'AND x=y AND a=b, AND r=s, etc.

While it's possible to do it the other way, it's much more work since you have to check which where clause is the first, and use where, and otherwise use AND...

Hope that explains it a bit more.
MG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top