Table of Contents
MySQL Interview Questions
🔒 Please log in to unlock this course.
Related Questions
Question 1
What is MySQL?
Locked. Enroll to open this question.
Question 2
What is the difference between SQL and MySQL?
Locked. Enroll to open this question.
Question 3
What is the difference between DBMS and RDBMS?
Locked. Enroll to open this question.
Question 4
What are the different types of SQL commands (DDL, DML, DCL, TCL, DQL)?
Locked. Enroll to open this question.
Question 5
What are the different data types in MySQL?
Locked. Enroll to open this question.
Question 6
What is the difference between CHAR and VARCHAR?
Locked. Enroll to open this question.
Question 7
What are the different types of keys in MySQL?
Locked. Enroll to open this question.
Question 8
What is the difference between a Primary Key and a Unique Key?
Locked. Enroll to open this question.
Question 9
What is a Foreign Key and how does it enforce referential integrity?
Locked. Enroll to open this question.
Question 10
What is the difference between DELETE, TRUNCATE, and DROP?
Locked. Enroll to open this question.
Question 11
What are constraints in MySQL and what are their types?
Locked. Enroll to open this question.
Question 12
What is the difference between NULL, zero, and an empty string?
Locked. Enroll to open this question.
Question 13
What is AUTO_INCREMENT and how does it work?
Locked. Enroll to open this question.
Question 14
What is the DEFAULT constraint and how does it differ from NULL?
Locked. Enroll to open this question.
Question 15
What is the difference between DECIMAL, FLOAT, and DOUBLE?
Locked. Enroll to open this question.
Question 16
What is the difference between DATETIME and TIMESTAMP?
Locked. Enroll to open this question.
Question 17
What is the difference between ENUM and SET data types?
Locked. Enroll to open this question.
Question 18
What is the difference between BLOB and TEXT?
Locked. Enroll to open this question.
Question 19
What are the basic CRUD operations in MySQL?
Locked. Enroll to open this question.
Question 20
What is the difference between the WHERE and HAVING clauses?
Locked. Enroll to open this question.
Question 21
What is the difference between the ORDER BY and GROUP BY clauses?
Locked. Enroll to open this question.
Question 22
What is the difference between DISTINCT and GROUP BY?
Locked. Enroll to open this question.
Question 23
What are the different types of operators in MySQL?
Locked. Enroll to open this question.
Question 24
What is the LIKE operator and what wildcards does it use?
Locked. Enroll to open this question.
Question 25
What is the difference between the IN and BETWEEN operators?
Locked. Enroll to open this question.
Question 26
What is the LIMIT clause and how is it used for pagination?
Locked. Enroll to open this question.
Question 27
What are aggregate functions in MySQL?
Locked. Enroll to open this question.
Question 28
What is the difference between COUNT(*), COUNT(column), and COUNT(1)?
Locked. Enroll to open this question.
Question 29
What are string functions in MySQL? Explain the common ones.
Locked. Enroll to open this question.
Question 30
What are date and time functions in MySQL?
Locked. Enroll to open this question.
Question 31
What are numeric and mathematical functions in MySQL?
Locked. Enroll to open this question.
Question 32
What is the difference between the CONCAT() and CONCAT_WS() functions?
Locked. Enroll to open this question.
Question 33
What are control flow functions like IF, IFNULL, CASE, and COALESCE?
Locked. Enroll to open this question.
Question 34
What is the difference between IFNULL(), NULLIF(), and COALESCE()?
Locked. Enroll to open this question.
Question 35
What is a JOIN and what are the different types of JOINs in MySQL?
Locked. Enroll to open this question.
Question 36
What is the difference between INNER JOIN and OUTER JOIN?
Locked. Enroll to open this question.
Question 37
How do you perform a FULL OUTER JOIN in MySQL?
Locked. Enroll to open this question.
Question 38
What is a SELF JOIN and when would you use it?
Locked. Enroll to open this question.
Question 39
What is a CROSS JOIN and how does it differ from an INNER JOIN?
Locked. Enroll to open this question.
Question 40
What is the difference between UNION and JOIN?
Locked. Enroll to open this question.
Question 41
What is the difference between UNION and UNION ALL?
Locked. Enroll to open this question.
Question 42
What is the difference between an EQUI JOIN and a NON-EQUI JOIN?
Locked. Enroll to open this question.
Question 43
What is a subquery and what are its types?
Locked. Enroll to open this question.
Question 44
What is a correlated subquery and how does it differ from a normal subquery?
Locked. Enroll to open this question.
Question 45
What is the difference between IN and EXISTS?
Locked. Enroll to open this question.
Question 46
What is the difference between the ANY, ALL, and SOME operators?
Locked. Enroll to open this question.
Question 47
What is a derived table (inline view) in MySQL?
Locked. Enroll to open this question.
Question 48
What is a Common Table Expression (CTE) and what are its advantages?
Locked. Enroll to open this question.
Question 49
What are the set operations (INTERSECT and MINUS/EXCEPT) and how do you achieve them in MySQL?
Locked. Enroll to open this question.
Question 50
What is an index in MySQL and how does it improve performance?
Locked. Enroll to open this question.
Question 51
What are the different types of indexes in MySQL?
Locked. Enroll to open this question.
Question 52
What is the difference between a clustered and a non-clustered index?
Locked. Enroll to open this question.
Question 53
What is a composite index and why does column order matter?
Locked. Enroll to open this question.
Question 54
What is the EXPLAIN statement and how do you use it to analyze queries?
Locked. Enroll to open this question.
Question 55
How do you optimize a slow query in MySQL?
Locked. Enroll to open this question.
Question 56
What is the difference between the InnoDB and MyISAM storage engines?
Locked. Enroll to open this question.
Question 57
What is index selectivity and cardinality, and why do they matter?
Locked. Enroll to open this question.
Question 58
What is a transaction and what are the ACID properties?
Locked. Enroll to open this question.
Question 59
What are COMMIT, ROLLBACK, and SAVEPOINT?
Locked. Enroll to open this question.
Question 60
What are the different transaction isolation levels in MySQL?
Locked. Enroll to open this question.
Question 61
What are dirty reads, non-repeatable reads, and phantom reads?
Locked. Enroll to open this question.
Question 62
What is locking in MySQL and what are the types of locks?
Locked. Enroll to open this question.
Question 63
What is a deadlock and how do you prevent it?
Locked. Enroll to open this question.
Question 64
What is the difference between optimistic and pessimistic locking?
Locked. Enroll to open this question.
Question 65
What is MVCC (Multi-Version Concurrency Control) in MySQL?
Locked. Enroll to open this question.
Question 66
What is a stored procedure and what are its advantages?
Locked. Enroll to open this question.
Question 67
What is the difference between a stored procedure and a function?
Locked. Enroll to open this question.
Question 68
What is a trigger and what are its types?
Locked. Enroll to open this question.
Question 69
What is a view and what are its advantages?
Locked. Enroll to open this question.
Question 70
What is the difference between a view and a materialized view?
Locked. Enroll to open this question.
Question 71
What is a cursor in MySQL and when should you use it?
Locked. Enroll to open this question.
Question 72
What are the different types of variables in MySQL?
Locked. Enroll to open this question.
Question 73
What is a temporary table and when do you use it?
Locked. Enroll to open this question.
Question 74
What is database normalization and what are the normal forms?
Locked. Enroll to open this question.
Question 75
What is denormalization and when should you use it?
Locked. Enroll to open this question.
Question 76
What is database replication in MySQL and what are its types?
Locked. Enroll to open this question.
Question 77
What is partitioning in MySQL and what are its types?
Locked. Enroll to open this question.
Question 78
How do you handle security and prevent SQL injection in MySQL?
Locked. Enroll to open this question.
Question 79
What are the best practices for MySQL database design and performance?
Locked. Enroll to open this question.
Question 80
A LEFT JOIN suddenly returns duplicate rows — why, and how do you fix it without using DISTINCT?
Locked. Enroll to open this question.
Question 81
Predict the output — why does WHERE created_at = '2026-08-02' miss rows even though the data…
Locked. Enroll to open this question.
Question 82
Predict the output — why does a NOT IN subquery return zero rows when the subquery contains a NULL?
Locked. Enroll to open this question.
Question 83
Predict the output — GROUP BY with a non-aggregated column in the SELECT (the ONLY_FULL_GROUP_BY…
Locked. Enroll to open this question.
Question 84
Predict the output — why does COUNT(*) show 1 for customers with zero orders in a LEFT JOIN?
Locked. Enroll to open this question.
Question 85
Predict the output — surprising results from integer division and implicit type conversion
Locked. Enroll to open this question.
Question 86
Your dashboard query suddenly takes 40 seconds in production — walk me through diagnosing it
Locked. Enroll to open this question.
Question 87
You added the perfect index but EXPLAIN still shows a full table scan — why does MySQL ignore an…
Locked. Enroll to open this question.
Question 88
What is the N+1 query problem, how do you detect it, and how do you fix it?
Locked. Enroll to open this question.
Question 89
Your query uses a composite index but is still slow — explain covering indexes and Index Condition…
Locked. Enroll to open this question.
Question 90
Deep pagination is killing your API — LIMIT 1000000, 20 takes 30 seconds. Why, and how do you fix…
Locked. Enroll to open this question.
Question 91
A big UPDATE/DELETE is locking your table and blocking the app — how do you run large batch…
Locked. Enroll to open this question.
Question 92
Find the 2nd highest salary per department, handling ties correctly
Locked. Enroll to open this question.
Question 93
Write a query to calculate a running total (cumulative sum) of daily sales
Locked. Enroll to open this question.
Question 94
The "gaps and islands" problem — find consecutive streaks of daily activity
Locked. Enroll to open this question.
Question 95
Pivot rows into columns — build a cross-tab report (MySQL has no native PIVOT)
Locked. Enroll to open this question.
Question 96
Find and delete duplicate rows while keeping exactly one copy — the safe production way
Locked. Enroll to open this question.
Question 97
Calculate the median salary in SQL (MySQL has no MEDIAN() function)
Locked. Enroll to open this question.
Question 98
RANK vs DENSE_RANK vs ROW_NUMBER — predict the exact output with tied values
Locked. Enroll to open this question.
Question 99
LEAD and LAG — compare each row to the previous/next (month-over-month growth)
Locked. Enroll to open this question.
Question 100
Window frames deep-dive — ROWS vs RANGE and the default-frame bug
Locked. Enroll to open this question.
Question 101
NTILE and percentiles — divide customers into quartiles/deciles for segmentation
Locked. Enroll to open this question.
Question 102
Show a detail row AND its group total/percentage in one query — aggregate window functions vs GROUP…
Locked. Enroll to open this question.
Question 103
A SELECT ... FOR UPDATE loop is causing deadlocks in production — diagnose and fix it
Locked. Enroll to open this question.
Question 104
The "lost update" problem — one user's update silently vanishes
Locked. Enroll to open this question.
Question 105
our nightly report shows inconsistent totals — phantom reads and choosing the right isolation
Locked. Enroll to open this question.
Question 106
Gap locks and next-key locks — why an INSERT mysteriously blocks under REPEATABLE READ
Locked. Enroll to open this question.
Question 107
Idempotency — how do you design a payment/INSERT that's safe to retry without double-charging?
Locked. Enroll to open this question.
Question 108
Design the database schema for a URL shortener like bit.ly
Locked. Enroll to open this question.
Question 109
Design a schema for a WhatsApp-style chat system (messages, conversations, read receipts)
Locked. Enroll to open this question.
Question 110
The EAV pattern for dynamic attributes — when to use it, why it's often an anti-pattern, and JSON…
Locked. Enroll to open this question.
Question 111
Soft delete vs hard delete — correct implementation, UNIQUE constraint pitfalls, and the…
Locked. Enroll to open this question.
Question 112
UUID vs auto-increment INT as primary key — the InnoDB performance impact and how ordered UUIDs fix…
Locked. Enroll to open this question.
Question 113
Your read replica is 3 hours behind during peak load — diagnose and fix replication lag
Locked. Enroll to open this question.
Question 114
How do you alter a 200-million-row table in production WITHOUT downtime?
Locked. Enroll to open this question.
Question 115
Database sharding — when to shard, choosing a shard key, and the problems it creates
Locked. Enroll to open this question.
Question 116
Your app throws "Too many connections" under load — connection pooling explained
Locked. Enroll to open this question.
Question 117
Your emoji and Bengali text turn into "???" — the utf8 vs utf8mb4 disaster
Locked. Enroll to open this question.
Question 118
The timezone disaster — timestamps shift by hours between servers and users
Locked. Enroll to open this question.
Question 119
The FLOAT money bug — why 0.1 + 0.2 isn't 0.3 and invoices show wrong totals
Locked. Enroll to open this question.
Question 120
How do you store, query, and index JSON data in MySQL?
Locked. Enroll to open this question.
Question 121
JSON_TABLE — convert a JSON array into relational rows
Locked. Enroll to open this question.
Question 122
JSON aggregation — build nested, API-ready JSON directly from SQL
Locked. Enroll to open this question.
Question 123
JSON column vs normalized tables vs EAV — the decision framework
Locked. Enroll to open this question.
Question 124
Full-Text Search — MATCH ... AGAINST vs LIKE '%text%'
Locked. Enroll to open this question.
Question 125
Boolean mode full-text search — precise, Google-style queries
Locked. Enroll to open this question.
Question 126
Generated columns — STORED vs VIRTUAL and indexing computed expressions
Locked. Enroll to open this question.
Question 127
Functional, invisible, and descending indexes — MySQL 8.0 index features
Locked. Enroll to open this question.
Question 128
mysqldump vs Percona XtraBackup — logical vs physical backups
Locked. Enroll to open this question.
Question 129
The binary log (binlog) — its role in replication, recovery, and the three formats
Locked. Enroll to open this question.
Question 130
Point-in-Time Recovery (PITR) — recover to the moment before an accidental DROP TABLE
Locked. Enroll to open this question.
Question 131
GRANT/REVOKE and the principle of least privilege
Locked. Enroll to open this question.
Question 132
Roles in MySQL 8.0 — managing permissions at scale
Locked. Enroll to open this question.
Question 133
How do you find slow queries in production? — slow query log, performance_schema, and sys schema
Locked. Enroll to open this question.
Question 134
Recursive CTEs — traverse a hierarchical org chart to any depth
Locked. Enroll to open this question.
Question 135
Recursive CTE — generate a date series to fill gaps in a report
Locked. Enroll to open this question.
Question 136
EXPLAIN ANALYZE — reading actual vs estimated rows to catch bad optimizer plans
Locked. Enroll to open this question.
Question 137
EXPLAIN ANALYZE — reading actual vs estimated rows to catch bad optimizer plans
Locked. Enroll to open this question.
Question 138
Find employees who earn more than their manager
Locked. Enroll to open this question.
Question 139
Rising Temperature — find days warmer than the previous day
Locked. Enroll to open this question.
Question 140
Consecutive Numbers — find values appearing 3+ times in a row
Locked. Enroll to open this question.
Question 141
Exchange Seats — swap adjacent students' seat numbers
Locked. Enroll to open this question.
Question 142
Find pairs of employees in the same department (no duplicate mirror pairs)
Locked. Enroll to open this question.
Question 143
Duplicate Emails — find emails that appear more than once
Locked. Enroll to open this question.
Question 144
Department Top 3 Salaries — top 3 earners in each department
Locked. Enroll to open this question.
Question 145
Nth Highest Salary — reusable query handling the "not enough rows" case
Locked. Enroll to open this question.
Question 146
Highest-paid employee (with name) in each department
Locked. Enroll to open this question.
Question 147
Rank Scores — build a leaderboard with no gaps in ranking
Locked. Enroll to open this question.
Question 148
Categorize salaries into bands and count employees per band
Locked. Enroll to open this question.
Question 149
Find managers with at least 5 direct reports
Locked. Enroll to open this question.
Question 150
Customers Who Never Order — the anti-join puzzle
Locked. Enroll to open this question.
Question 151
Human Traffic of a Stadium — 3+ consecutive high-attendance days
Locked. Enroll to open this question.
Question 152
Trips and Users — calculate the daily cancellation rate
Locked. Enroll to open this question.
Question 153
Tree Node Type — classify each node as Root, Inner, or Leaf
Locked. Enroll to open this question.
Question 154
Monthly Transactions — totals split by status with conditional aggregation
Locked. Enroll to open this question.
Question 155
Users active in consecutive months (capstone puzzle)
Locked. Enroll to open this question.
Get Interview Mastery: The Complete Guide for Candidates and Interviewers updates by email
Short, practical lessons and course updates from Rumman Ansari. No spam.