Beginners often ask: “Do I learn SQL or MySQL?” The answer is both, and they are not the same thing.
- SQL (Structured Query Language) is a language. It is the way you tell a database what you want.
- MySQL is a database program that understands SQL.
An analogy: English is a language. A specific person who speaks English is not the language. In the same way, SQL is the language, and MySQL, PostgreSQL, SQL Server, Oracle and SQLite are different programs that speak it.
One standard, many dialects
SQL has an international standard, so the basic commands look the same everywhere:
SELECT 1 + 1 AS result;
+--------+
| result |
+--------+
| 2 |
+--------+
1 row in set
That query works in nearly every database. But each database adds its own extras and sometimes does things slightly differently. Those differences are called dialects.
| Task | MySQL | PostgreSQL | SQL Server |
|---|---|---|---|
| Limit the number of rows | LIMIT 5 | LIMIT 5 | TOP 5 or FETCH FIRST 5 ROWS ONLY |
| Auto-numbered ID | AUTO_INCREMENT | GENERATED ... AS IDENTITY | IDENTITY(1,1) |
| Join text together | CONCAT(a, b) | a || b or CONCAT(a, b) | CONCAT(a, b) or + |
| Current date and time | NOW() | NOW() | GETDATE() |
How this course marks it
- Anything the standard defines and most databases support is called standard SQL.
- Anything specific to MySQL is called MySQL syntax or MySQL-specific. Examples:
AUTO_INCREMENT,LIMIT,ON DUPLICATE KEY UPDATE,SHOW TABLES.
If you later move to another database, the standard parts transfer directly, and the MySQL-specific parts need a quick translation.
MySQL and MariaDB
MariaDB is a separate database that started as a copy (“fork”) of MySQL in 2009. It looks and feels very similar, and many tools (including XAMPP and some hosting plans) install MariaDB under the name “MySQL”. Basic SQL works on both, but newer features have drifted apart: the JSON type, window functions, some index features and the system tables differ in details. This course targets MySQL 8.4 and later. If your server says MariaDB, most lessons still work, and the course points out important differences.
You can see which server you have:
SELECT @@version_comment AS server;
+------------------------------+
| server |
+------------------------------+
| MySQL Community Server - GPL |
+------------------------------+
1 row in set
Case matters less than you think
SELECT can be written in capitals or lowercase. People write keywords in capitals by habit, to separate them from table and column names. The SQL Case Sensitivity lesson covers the exceptions.