Field Manual PHP / Laravel reference
← SQL

UPDATE

UPDATE changes matching rows.

What it is

UPDATE changes matching rows.

When to use it

Change state or attributes under an explicit condition.

Syntax

UPDATE orders SET status = ? WHERE id = ? AND status = ?;

Example

UPDATE orders SET status = 'paid'
WHERE id = 42 AND status = 'pending';
-- Check affected row count; zero means missing/conflicting state.

Common mistakes

Missing WHERE updates every row; read-then-write without conditions races.

Related topics

Browse SQL