🐘 PostgreSQL
Beginner
How do you query data in PostgreSQL?
Answer
The SELECT statement retrieves data. Basic form: SELECT column1, column2 FROM tablename WHERE condition ORDER BY column DESC LIMIT 10;. SELECT * retrieves all columns (avoid in production for performance and clarity). Filter with WHERE: operators =, !=, <, >, BETWEEN, IN (list), LIKE, ILIKE (case-insensitive), IS NULL, IS NOT NULL. Combine conditions with AND, OR, NOT. Aliases: SELECT name AS full_name. Computed columns: SELECT price * quantity AS total. Distinct values: SELECT DISTINCT country FROM users.