Both speak SQL; defaults and features diverge. MySQL dominates shared hosting and WordPress; Postgres leads many new SaaS products—see PostgreSQL track for JSONB, RETURNING, and extensions.
Syntax differences (sample)
-- MySQL: AUTO_INCREMENT, backticks optional
CREATE TABLE demo (
id INT AUTO_INCREMENT PRIMARY KEY,
active TINYINT(1) NOT NULL DEFAULT 1,
meta JSON
);
INSERT INTO demo (meta) VALUES ('{"k": 1}');
SELECT LAST_INSERT_ID();Practice: Copy SQL into the mysql client, local MySQL/MariaDB, or DB Fiddle (MySQL dialect).
When MySQL often wins
- Team/hosting already on MySQL or MariaDB
- WordPress/PHP ecosystem and cheap managed instances
- Simple OLTP with well-defined relational schema
When Postgres often wins
Complex analytics SQL, geospatial (PostGIS), strict SQL semantics, and rich JSONB indexing—portable SQL from SQL track still applies on either engine.
Important interview questions and answers
- Q: LAST_INSERT_ID()?
A: Returns AUTO_INCREMENT value from current session after INSERT. - Q: RETURNING in MySQL?
A: Supported in MySQL 8.0.21+ for INSERT/UPDATE/DELETE—Postgres had it longer.
Self-check
- How do you read the new row id after INSERT in classic MySQL?
- Name one JSON storage type in MySQL 5.7+.
Tip: LAST_INSERT_ID() is per session—safe in one PHP request.
Interview prep
- AUTO_INCREMENT?
Integer key generated on INSERT; read with LAST_INSERT_ID().
- JSON in MySQL?
Native JSON type with -> and ->> operators (5.7+).