Chuck Conway
Chuck Conway

Reputation: 16435

What is a 'naked where clause'

In a conversation with my coworker, he mentioned he accidentally deployed a 'naked where clause' into production.

What is a 'naked where clause'?

Upvotes: 5

Views: 226

Answers (1)

Matt Busche
Matt Busche

Reputation: 14333

a naked WHERE clause would refer to something that always returns true

WHERE 1 = 1

This is commonly used on something like a search form where the user can enter one or many values and rather than checking a counter to see if you need to add a WHERE clause you add a generic WHERE clause and build everything up in an AND clause. You can run into issues if you aren't checking to make sure there is at least on AND clause added.

Upvotes: 10

Related Questions