DISTINCTSelect distinct valuesin a column WHERE Filter rows using a condition AND, OR, NOTCombine multiple conditions ORDER BY Sort the set result by a column LIMIT & OFFSETLimit the number of rows and skip rows GROUP BY Group rows with the same values in specified columns HAVING Filter the results of a GROUP BY
Check out our Developers Community: https://www.thealpha.dev/
Joining Tables
INNER JOIN Combine rows from related tables based
on a condition LEFT JOIN Return all rows from the left table and the matched rows from the right table RIGHT JOIN Return all rows from the right table and the matched rows from the left table FULL JOIN Return all rows when there's a match in either table CROSS JOIN Return the Cartesian product of two tables SELF JOIN Join a table to itself using aliases
Check out our Developers Community: https://www.thealpha.dev/
Aggregating & Analysing data
COUNT()Count the number of rows
SUM() Calculate the sum of a column AVG() Calculate the average of a column MIN() & MAX() Find the minimum & maximum value in a column GROUP_CONTACT() Concatenate values from a group
Check out our Developers Community: https://www.thealpha.dev/
SQL Functions & Expressions
COALESCE() Return the first non-null value from a list
NULLIF() Return null if two expressions are equal CASE Perform conditional logic in SQL queries CAST Convert a value to a specified data type CONCAT() Concatenate two or more strings
Check out our Developers Community: https://www.thealpha.dev/
Working with Tables
CREATE TABLECreate a new table
ALTER TABLEModifying an existing table DROP TABLERemove a table TRUNCATE TABLERemove all rows from a table without deleting the table structure RENAME TABLE Rename a table
Check out our Developers Community: https://www.thealpha.dev/
Constraints & Indexes
PRIMARY KEY Uniquely identify each row in a table
FOREIGN KEY Ensure refrential integrity between two tables UNIQUE Ensure unique values in a column CHECK Ensure that all values in a column satisfy a condition DEFAULT Set a default value for a column NOT NULL Ensure a column cannot contain null values CREATE INDEX Create an index on a table DROP INDEX Remove an index
Check out our Developers Community: https://www.thealpha.dev/
Views, Stored Procedures & Triggers
CREATE VIEW Create a virtual table based on a
SELECT statement DROP VIEW Remove a view CREATE PROCEDURE Create a stored procedure EXECUTE Run a stored procedure DROP PROCEDURE Remove a stored procedure CREATE TRIGGER Create a trigger that executes a specified action when an event occurs DROP TRIGGER Remove a trigger
Check out our Developers Community: https://www.thealpha.dev/
User Management
CREATE USER Create a new user
DROP USER Remove a user ALTER USER Change the password of a use GRANT Give a user access to specific privileges REVOKE Remove a user's access to specific privileges
Check out our Developers Community: https://www.thealpha.dev/