dev.rean.me
database

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

Share:

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

MySQLSQL ServerPostgreSQL
Made byOracleMicrosoftPostgreSQL community
PriceFree (Community)Paid, but free Express and Developer edition100% free
Operating systemWindows, Linux, macOSWindows, Linux, DockerWindows, Linux, macOS
SQL language nameSQL (MySQL style)T-SQL (Transact-SQL)SQL + PL/pgSQL
GUI toolMySQL WorkbenchSSMS (SQL Server Management Studio)pgAdmin
Command-line toolmysqlsqlcmdpsql
Best forWebsite, WordPress, PHP appCompany system, .NET app, reportComplex app, big data, GIS, JSON
Popular userFacebook, YouTube, WordPressBank, business, Microsoft shopApple, 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_INCREMENT vs IDENTITY(1,1) vs SERIAL
  • True/false: BOOLEAN vs BIT vs BOOLEAN
  • Current time: NOW() vs GETDATE() vs NOW()
  • SQL Server use NVARCHAR for 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

MySQLSQL ServerPostgreSQL (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:

MySQLSQL ServerPostgreSQL
`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%' find Sok. โœ…
  • PostgreSQL: Care about case! LIKE 's%' not find Sok. โŒ Use ILIKE instead:
SELECT * FROM students WHERE name ILIKE 's%';

4. Summary of Syntax Difference

TaskMySQLSQL ServerPostgreSQL
Auto IDAUTO_INCREMENTIDENTITY(1,1)SERIAL
Limit rowLIMIT 3TOP 3LIMIT 3
Current timeNOW()GETDATE()NOW()
True/FalseBOOLEANBITBOOLEAN
Join textCONCAT()+ or CONCAT()|| or CONCAT()
Switch databaseUSE db;USE db;\c db
Quote name`name`[name]"name"
UpsertON DUPLICATE KEY UPDATEMERGEON CONFLICT DO UPDATE
Case searchNot care caseNot care caseCare 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 NVARCHAR and N'text' for Khmer text, or it show ????.
  • In PostgreSQL, remember LIKE care about upper/lower case. Use ILIKE when 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! ๐Ÿ’ก