MySQL vs SQL Server vs PostgreSQL: What Is the Difference?
Compare MySQL, SQL Server, and PostgreSQL in very simple English, with same SQL example in all 3 database and easy tips for beginner to choose.
2026-10-29 ยท 7 min read
Hello my friend! ๐ค MySQL, SQL Server, PostgreSQL... which one should I learn? Which one should I use? Many beginner ask this. Today we compare all 3 together with real example. Let's go!
1. Meet the 3 Database
All 3 is RDBMS (Relational Database Management System). All keep data in table, and all use SQL. But each one have its own style.
- ๐ฌ MySQL: Very popular for website. Own by Oracle. Free Community version.
- ๐ช SQL Server: Made by Microsoft. Popular in company and business that use Microsoft tool. Have free Express and Developer edition.
- ๐ PostgreSQL: Fully open-source and free. Very powerful, follow SQL standard very close.
2. Quick Comparison Table
| MySQL | SQL Server | PostgreSQL | |
|---|---|---|---|
| Made by | Oracle | Microsoft | PostgreSQL community |
| Price | Free (Community) | Paid, but free Express and Developer edition | 100% free |
| Operating system | Windows, Linux, macOS | Windows, Linux, Docker | Windows, Linux, macOS |
| SQL language name | SQL (MySQL style) | T-SQL (Transact-SQL) | SQL + PL/pgSQL |
| GUI tool | MySQL Workbench | SSMS (SQL Server Management Studio) | pgAdmin |
| Command-line tool | mysql | sqlcmd | psql |
| Best for | Website, WordPress, PHP app | Company system, .NET app, report | Complex app, big data, GIS, JSON |
| Popular user | Facebook, YouTube, WordPress | Bank, business, Microsoft shop | Apple, Instagram, Reddit |
3. Same Task, Different Code
Most basic SQL is same in all 3: SELECT, WHERE, JOIN, GROUP BY, ORDER BY... But some thing is different. Let's see!
3.1 Create Database and Switch to It
MySQL:
CREATE DATABASE school;
USE school;
SQL Server:
CREATE DATABASE school;
GO
USE school;
GO
PostgreSQL:
CREATE DATABASE school;
\c school
PostgreSQL don't have USE. In psql, use \c to connect.
3.2 Create Table with Auto Number ID
MySQL use AUTO_INCREMENT:
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
is_active BOOLEAN DEFAULT TRUE,
created_at DATETIME DEFAULT NOW()
);
SQL Server use IDENTITY(1,1):
CREATE TABLE students (
id INT IDENTITY(1,1) PRIMARY KEY,
name NVARCHAR(50) NOT NULL,
is_active BIT DEFAULT 1,
created_at DATETIME DEFAULT GETDATE()
);
PostgreSQL use SERIAL:
CREATE TABLE students (
id SERIAL PRIMARY KEY,
name VARCHAR(50) NOT NULL,
is_active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT NOW()
);
See the difference?
- Auto number:
AUTO_INCREMENTvsIDENTITY(1,1)vsSERIAL - True/false:
BOOLEANvsBITvsBOOLEAN - Current time:
NOW()vsGETDATE()vsNOW() - SQL Server use
NVARCHARfor Unicode text (like Khmer language โ ).
3.3 Get Only First 3 Row
MySQL and PostgreSQL use LIMIT:
SELECT * FROM students ORDER BY id LIMIT 3;
SQL Server use TOP:
SELECT TOP 3 * FROM students ORDER BY id;
3.4 Pagination (Skip Some Row)
Show 10 student, skip first 20 (page 3):
MySQL and PostgreSQL:
SELECT * FROM students ORDER BY id LIMIT 10 OFFSET 20;
SQL Server:
SELECT * FROM students
ORDER BY id
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
3.5 Join Text Together
Want to show "Sok - Active":
MySQL:
SELECT CONCAT(name, ' - Active') FROM students;
SQL Server:
SELECT name + ' - Active' FROM students;
PostgreSQL:
SELECT name || ' - Active' FROM students;
Good news: CONCAT() work in all 3! Use it if you want same code everywhere.
3.6 Show All Table
| MySQL | SQL Server | PostgreSQL (psql) |
|---|---|---|
SHOW TABLES; | SELECT * FROM INFORMATION_SCHEMA.TABLES; | \dt |
3.7 Name with Space or Special Word
If column name have space or is special word, each one use different quote:
| MySQL | SQL Server | PostgreSQL |
|---|---|---|
`full name` | [full name] | "full name" |
3.8 Insert or Update if Already Exist (Upsert)
If student with id = 1 already exist, update the name. If not, insert new one.
MySQL:
INSERT INTO students (id, name) VALUES (1, 'Sok')
ON DUPLICATE KEY UPDATE name = 'Sok';
PostgreSQL:
INSERT INTO students (id, name) VALUES (1, 'Sok')
ON CONFLICT (id) DO UPDATE SET name = 'Sok';
SQL Server use MERGE:
MERGE students AS t
USING (SELECT 1 AS id, N'Sok' AS name) AS s
ON t.id = s.id
WHEN MATCHED THEN UPDATE SET t.name = s.name
WHEN NOT MATCHED THEN INSERT (name) VALUES (s.name);
Note: In SQL Server, IDENTITY column not allow insert id by yourself (unless turn on IDENTITY_INSERT), so we only insert name.
3.9 Search Upper/Lower Case
Find name start with "s" (small letter):
- MySQL and SQL Server: Default not care upper or lower case.
WHERE name LIKE 's%'findSok. โ - PostgreSQL: Care about case!
LIKE 's%'not findSok. โ UseILIKEinstead:
SELECT * FROM students WHERE name ILIKE 's%';
4. Summary of Syntax Difference
| Task | MySQL | SQL Server | PostgreSQL |
|---|---|---|---|
| Auto ID | AUTO_INCREMENT | IDENTITY(1,1) | SERIAL |
| Limit row | LIMIT 3 | TOP 3 | LIMIT 3 |
| Current time | NOW() | GETDATE() | NOW() |
| True/False | BOOLEAN | BIT | BOOLEAN |
| Join text | CONCAT() | + or CONCAT() | || or CONCAT() |
| Switch database | USE db; | USE db; | \c db |
| Quote name | `name` | [name] | "name" |
| Upsert | ON DUPLICATE KEY UPDATE | MERGE | ON CONFLICT DO UPDATE |
| Case search | Not care case | Not care case | Care case, use ILIKE |
5. Which One Should I Choose?
๐ฌ Choose MySQL if:
- You build website with PHP, WordPress, or Laravel.
- You want easy to start and many tutorial online.
- Your hosting already support MySQL (most cheap hosting do).
๐ช Choose SQL Server if:
- Your company use Microsoft tool (.NET, C#, Azure, Power BI).
- You want strong tool like SSMS and report service.
- You want find job in bank or big company that use Microsoft.
๐ Choose PostgreSQL if:
- You want 100% free and open-source with no limit.
- Your app need complex query, JSON, array, or map/location (PostGIS).
- You use Python (Django), Node.js, or modern cloud like Supabase.
Tips
- Don't worry too much which one first! About 80% of SQL is same. Learn one good, then other become easy.
- For beginner, start with MySQL or PostgreSQL. Both free and easy to install.
- If you study in Cambodia and want work in bank or big company, learn SQL Server too. Many company here use it.
- Write standard SQL when you can (like
CONCAT(),OFFSET,INFORMATION_SCHEMA). Then move to other database later is easy. - In SQL Server, always use
NVARCHARandN'text'for Khmer text, or it show????. - In PostgreSQL, remember
LIKEcare about upper/lower case. UseILIKEwhen you not sure. - Install all 3 with Docker for practice. Easy to start and delete, no make your computer messy.
Conclusion
MySQL, SQL Server, and PostgreSQL is all great relational database. MySQL is popular for website, SQL Server is strong in Microsoft world, and PostgreSQL is free and very powerful. Most SQL is same, only some small syntax different. Pick one, practice every day, and you can learn other later. Keep going my friend! ๐ก