<p>Why would someone use <code>WHERE 1=1 AND &lt;conditions&gt;</code> in a SQL clause (Either SQL obtained through concatenated strings, either view definition)</p>

<p>I've seen somewhere that this would be used to protect against SQL Injection, but it seems very weird.</p>

<p>If there is injection <code>WHERE 1 = 1 AND injected OR 1=1</code> would have the same result as <code>injected OR 1=1</code>.</p>

<p>Later edit: What about the usage in a view definition?</p>

<hr>

<p>Thank you for your answers.</p>

<p>Still,
I don't understand why would someone use this construction for defining a view, or use it inside a stored procedure.</p>

<p>Take this for example:</p>

<pre><code>CREATE VIEW vTest AS
SELECT FROM Table WHERE 1=1 AND table.Field=Value
</code></pre>

If the list of conditions is not known at compile time and is instead built at run time, you don't have to worry about whether you have one or more than one condition. You can generate them all like:
```
```
and <condition>
```
```
and concatenate them all together. With the
```
1=1
```
at the start, the initial
```
and
```
has something to associate with.
I've never seen this used for any kind of injection protection, as you say it doesn't seem like it would help much. I
have
seen it used as an implementation convenience. The SQL query engine will end up ignoring the
```
1=1
```
so it should have no performance impact.