CodShot
SQL Public

Update Rows with Join

Update rows in one table using values from another table.

#sql #update #join #mysql
SQL
UPDATE products p
INNER JOIN categories c
    ON c.id = p.category_id
SET p.category_name_cache = c.name
WHERE p.category_id IS NOT NULL;

Notes

Always test UPDATE queries with a SELECT first, especially on production data.

Snippet actions

CodShot user
CodShot user
Updated: 2026-06-03 15:31
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support