00:00

MySQL Vs SQL

Last updated: 4 min read

Beginners often ask "Should I learn SQL or MySQL?" The short answer: both, because they are different kinds of things. SQL is a language. MySQL is a database management system (software) that you talk to using that language. This tutorial makes the difference clear with an analogy, a comparison table and examples.

1. An Everyday Analogy

Think of SQL as English and MySQL as a person who speaks English. Many people speak English (MySQL, PostgreSQL, Oracle, SQL Server), each with a slightly different accent and a few local words. If you learn the language, you can talk to any of them; if you learn one person's accent too, you can use their special phrases.

SQL is the language, MySQL is one database that speaks itSQL in the middle as the common language. MySQL, PostgreSQL, Oracle, SQL Server and SQLite are database systems that each understand SQL, with their own extra features called dialects.SQLthe standard languageMySQLspeaks SQL + own dialectPostgreSQLspeaks SQL + own dialectOraclespeaks SQL + own dialectSQL Serverspeaks SQL + own dialectSQLitespeaks SQL + own dialect
Figure 1: SQL is one language shared by many database systems. MySQL is one of those systems.

2. What is SQL?

  • Structured Query Language, created at IBM in the 1970s.
  • An ANSI/ISO standard (first in 1986/87, latest SQL:2023).
  • A declarative language for defining, querying and changing relational data.
  • It is not a program you install; it is text that a database understands.
  • Groups of commands: DDL, DML, DQL, DCL and TCL (see What is SQL).

3. What is MySQL?

  • A relational database management system (RDBMS): real software you install and run.
  • Created by MySQL AB in 1995 and owned by Oracle since 2010.
  • Open source (Community Edition, GPL) with a commercial Enterprise Edition.
  • Stores data on disk, manages users, runs queries, handles transactions, backups and replication.
  • Uses SQL as its language, plus MySQL-specific extensions.

4. MySQL vs SQL: Comparison Table

PointSQLMySQL
What it isA query languageA database management system (software)
Created byIBM researchers (Chamberlin and Boyce), standardised by ANSI/ISOMySQL AB (Widenius, Axmark, Larsson); now Oracle
Installed?No, nothing to installYes, a server (mysqld) plus client tools
Stores data?NoYes, in tables managed by storage engines like InnoDB
Changes over timeNew standard versions (SQL:2016, SQL:2023)New releases (8.0, 8.4 LTS, 9.x)
Used withAny relational databaseApplications, tools and drivers that connect to MySQL
LicenceA standard document; the language itself is free to useGPL (Community) or commercial (Enterprise)
AlternativesOther query languages: MongoDB's MQL, Cassandra's CQL, CypherPostgreSQL, Oracle, SQL Server, MariaDB, SQLite

5. One Query, Any Database

This statement is plain standard SQL. It runs unchanged on MySQL (below), PostgreSQL, SQL Server, Oracle and SQLite:

standard.sql
CREATE DATABASE demo;
USE demo;
CREATE TABLE cities (name VARCHAR(30), state VARCHAR(30), population INT);
INSERT INTO cities VALUES ('Mumbai','Maharashtra',12442373),('Pune','Maharashtra',3124458),
                          ('Bengaluru','Karnataka',8443675),('Mysuru','Karnataka',920550);

SELECT state, SUM(population) AS total_population
FROM cities
GROUP BY state
ORDER BY total_population DESC;

Result: 2 rows

statetotal_population
Maharashtra15566831
Karnataka9364225

6. MySQL's Own Dialect

MySQL also has its own extras that aren't in the standard or that other databases spell differently. For example, MySQL does not support the standard FETCH FIRST clause; it uses LIMIT instead:

TaskMySQLStandard SQL / others
First 2 rowsLIMIT 2FETCH FIRST 2 ROWS ONLY; SQL Server: TOP 2
Join stringsCONCAT(a, b) (|| means OR by default)a || b
Auto-numbered IDAUTO_INCREMENTGENERATED ALWAYS AS IDENTITY
Insert or updateINSERT … ON DUPLICATE KEY UPDATEMERGE
Quote a name`order`"order"
Show tablesSHOW TABLESQuery information_schema.tables
mysql-dialect.sql
SELECT CONCAT(name, ' (', state, ')') AS city
FROM cities
ORDER BY population DESC
LIMIT 2;

Result: 2 rows

city
Mumbai (Maharashtra)
Bengaluru (Karnataka)
query.sql
-- skip the first 2 rows and return the next 2 (rows 3 and 4)
SELECT name FROM cities ORDER BY population DESC
LIMIT 2 OFFSET 2;

Result: 2 rows

name
Pune
Mysuru

7. Which Should You Learn First?

  • Learn SQL concepts (SELECT, WHERE, JOIN, GROUP BY, transactions). They transfer to every relational database.
  • Practise on MySQL (or any RDBMS), because you need a real database to run SQL.
  • Then learn the MySQL-specific parts you need: installation, users, storage engines, backups, tuning.
  • Job adverts that say "SQL" usually mean the language; adverts that say "MySQL DBA" mean the product skills.

8. Common Misunderstandings

MythReality
MySQL is a language.MySQL is software. The language is SQL.
SQL is only for MySQL.SQL works with every relational database.
SQL Server and SQL are the same.SQL Server is Microsoft's RDBMS; like MySQL, it uses SQL (its dialect is T-SQL).
Knowing MySQL means you know every database.The core SQL transfers, but each product differs in features, tools and administration.

9. Summary

  • SQL is a standard language; MySQL is a database system that uses it.
  • You can't install SQL, but you can install MySQL.
  • Standard SQL runs on many databases; each adds its own dialect (MySQL: LIMIT, AUTO_INCREMENT, back-tick quoting…).
  • Learn SQL concepts and practise them on MySQL.