---
title: "Why Use 1=0 and 1=1 in SQL Queries?"
description: "The expressions 1=0 and 1=1 in SQL serve specific purposes: 1=0 prevents row retrieval, while 1=1 facilitates dynamic querying across various relational database systems."
url: https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/
date: 2024-09-23
modified: 2026-10-05
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2024/09/image-23.png?fit=1024%2C768&ssl=1
categories: ["SQL"]
tags: ["SQL expression 1=0 and 1=1"]
type: post
lang: en
---

# Why Use 1=0 and 1=1 in SQL Queries?

The expressions `1=0` and `1=1` are commonly used in SQL across many databases. Nearly all relational database management systems (RDBMS) support them. This is because they adhere to standard SQL logic.

![Why use 1 0 and 1 1 in sql queries example](https://i0.wp.com/srinimf.com/wp-content/uploads/2024/09/spring-flowers-flowers-collage-floral-68507.jpeg?resize=1733%2C1300&ssl=1)*Photo by Pixabay on Pexels.com*

## Why use 1=0 and 1=1 in SQL Queries Example

1. [Why use 1=0 and 1=1 in SQL Queries Example](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/#why-use-1-0-and-1-1-in-sql-queries-example)
   1. [Where 1=0 in SQL example](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/#where-1-0-in-sql-example)
   2. [Where 1=0 in SQL](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/#where-1-0-in-sql)
   3. [Supported databases](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/#supported-databases)

### Where 1=0 in SQL example

- **`1=0`**: This condition is always false. It is often used to prevent any rows from being returned or affected. For instance, creating an empty result set.

```
SELECT * FROM table WHERE 1=0; -- Always returns no rows
```

-

### Where 1=0 in SQL

- **`1=1`**: This condition is always true. It’s sometimes used in dynamic SQL to make it easier to append extra `AND` conditions. For example:

```
SELECT * FROM table WHERE 1=1 AND column = 'value'; -- Always returns rows matching the column condition
```

### Supported databases

Most RDBMS support these expressions:

- **MySQL**
- **PostgreSQL**
- **Microsoft SQL Server**
- **Oracle**
- **SQLite**
- **MariaDB**
- **IBM Db2**

These conditions rely on basic boolean logic, which all SQL engines handle. So, it’s a universal SQL feature, not specific to any particular database engine.

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2024%2F09%2F23%2Fwhy-use-10-and-11-in-sql-queries%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2024%2F09%2Fimage-23.png%3Ffit%3D1024%252C768%26ssl%3D1&description=Why%20Use%201%3D0%20and%201%3D1%20in%20SQL%20Queries%3F)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2024/09/23/why-use-10-and-11-in-sql-queries/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Why%20Use%201%3D0%20and%201%3D1%20in%20SQL%20Queries%3F&body=https%3A%2F%2Fsrinimf.com%2F2024%2F09%2F23%2Fwhy-use-10-and-11-in-sql-queries%2F&share=email)
-

### Like this:

Like Loading…