# What is SELECT FOR UPDATE in SQL (with examples)?

DevFeed: [What is SELECT FOR UPDATE in SQL (with examples)?](<https://devfeed.tech/articles/what-is-select-for-update-in-sql-with-examples-23815.md>)

Original publisher: [Read original article](<https://cockroachlabs.com/blog/select-for-update>)

Author: Charlie Custer

Published: 2022-06-27T00:00:00Z

Content type: tutorial

Language: en

Sources: [Cockroach Labs](<https://devfeed.tech/sources/cockroach-labs.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Transactions](<https://devfeed.tech/topics/transactions.md>), [CockroachDB](<https://devfeed.tech/topics/cockroachdb.md>), [consistency](<https://devfeed.tech/topics/consistency.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [SQLite](<https://devfeed.tech/topics/sqlite.md>), [Latency](<https://devfeed.tech/topics/latency.md>)

Tags: [cockroachdb](<https://devfeed.tech/tags/cockroachdb.md>), [consistency](<https://devfeed.tech/tags/consistency.md>), [databases](<https://devfeed.tech/tags/databases.md>), [latency](<https://devfeed.tech/tags/latency.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [performance](<https://devfeed.tech/tags/performance.md>), [relational-databases](<https://devfeed.tech/tags/relational-databases.md>), [sql](<https://devfeed.tech/tags/sql.md>), [sqlite](<https://devfeed.tech/tags/sqlite.md>), [transactions](<https://devfeed.tech/tags/transactions.md>)

## AI overview

This tutorial explains SELECT FOR UPDATE in SQL, including how it locks rows during transactions, queues competing transactions, and can reduce retries and tail latency. It compares support and transaction behavior across MySQL, SQLite, and CockroachDB.

## Source excerpt

Relational databases are great for transactional workloads. But things can get messy when multiple transactions start trying to access the same data at the same time. Luckily, in many SQL databases there's a solution for that: SELECT FOR UPDATE.