Skip to main content

287 posts tagged with "MySQL"

MySQL Relational Database Server and Its Tools

View All Tags

Why MySQL AUTO_INCREMENT IDs Have Gaps

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Your table's IDs go 1, 2, 5, 7, 12, and you can't account for the missing numbers. Nothing is wrong. MySQL hands out an AUTO_INCREMENT value before it knows whether the insert will succeed, and it doesn't take the value back. Here's that happening on MySQL 9.7, in two different ways.

How to Join Two Tables in MySQL

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

A product row holds a CategoryId, not a category's name. A JOIN brings the two tables together, so you can read both in one result. INNER JOIN keeps only the rows that match, and LEFT JOIN keeps every row from the first table. This guide runs both on MySQL 9.7, and shows a counting mistake that's easy to make.

How to Count Rows in a MySQL Table

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

SELECT COUNT(*) FROM table tells you how many rows a table has. Add WHERE to count only some of them, or GROUP BY to count per category. There's one trap: COUNT(column) skips NULLs, so it can give a smaller number than you expect. All of it is run here on MySQL 9.7.

How to Update Rows in a MySQL Table Safely

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

An UPDATE with the wrong WHERE, or no WHERE at all, can change every row in a table, and there's no undo afterwards. A few habits make it safe: check the rows with a SELECT first, read what MySQL reports, and use a transaction when it matters. This guide does all of those on MySQL 9.7.