PostgreSQL is known for its strong SQL standards compliance and extensibility features. MySQL is often chosen for its speed and simplicity, especially in web applications.
SELECT data->>'name' FROM users WHERE id = 1;
PostgreSQL supports the ->> operator to extract JSON fields as text. MySQL does not support this operator and would raise an error.
INSERT INTO products (id, name) VALUES (1, 'Pen') ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name;
PostgreSQL supports the ON CONFLICT clause for UPSERT operations. MySQL uses a different syntax (ON DUPLICATE KEY UPDATE) and will raise a syntax error for this query.
PostgreSQL supports GIN indexes which are efficient for full-text search. MySQL does not support GIN indexes and uses different mechanisms for full-text search.
SELECT * FROM orders WHERE order_date = '2023-02-30';
Why does it fail in PostgreSQL but not in MySQL?
MySQL treats '2023-02-30' as NULL causing no results, PostgreSQL throws an error.
