|
SELECT | Retrieve data from a database | SELECT column1, column2 FROM table_name; |
INSERT | Insert new data into a database | INSERT INTO table_name (column1, column2) VALUES (value1, value2); |
UPDATE | Modify existing data in a database | UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition; |
DELETE | Delete data from a database | DELETE FROM table_name WHERE condition; |
CREATE DATABASE | Create a new database | CREATE DATABASE database_name; |
CREATE TABLE | Create a new table | CREATE TABLE table_name (column1 datatype, column2 datatype); |
DROP DATABASE | Delete a database | DROP DATABASE database_name; |
DROP TABLE | Delete a table | DROP TABLE table_name; |
ALTER TABLE | Modify an existing table | ALTER TABLE table_name ADD column datatype; |
SHOW DATABASES | Display a list of all databases | SHOW DATABASES; |
SHOW TABLES | Display a list of all tables in a database | SHOW TABLES; |
DESC | Display information about a table | DESC table_name; |
LIKE | Search for data that matches a specific pattern | SELECT * FROM table_name WHERE column LIKE 'pattern'; |
IN | Search for data that matches a list of values | SELECT * FROM table_name WHERE column IN (value1, value2); |
BETWEEN | Search for data that falls within a range | SELECT * FROM table_name WHERE column BETWEEN value1 AND value2; |
ORDER BY | Sort data in ascending or descending order | SELECT * FROM table_name ORDER BY column ASC/DESC; |
GROUP BY | Group data by a specific column | SELECT column, COUNT(*) FROM table_name GROUP BY column; |
HAVING | Filter data based on aggregate functions | SELECT column, COUNT() FROM table_name GROUP BY column HAVING COUNT() > value; |
DISTINCT | Retrieve unique values from a column | SELECT DISTINCT column FROM table_name; |
COUNT | Count the number of rows in a table | SELECT COUNT(*) FROM table_name; |
SUM | Calculate the sum of values in a column | SELECT SUM(column) FROM table_name; |
AVG | Calculate the average value of a column | SELECT AVG(column) FROM table_name; |
MAX | Retrieve the highest value in a column | SELECT MAX(column) FROM table_name; |
MIN | Retrieve the lowest value in a column | SELECT MIN(column) FROM table_name; |
JOIN | Combine data from multiple tables | SELECT * FROM table1 JOIN table2 ON table1.column = table2.column; |
LEFT JOIN | Combine data from two tables, including all rows from the left table | SELECT * FROM table1 LEFT JOIN table2 ON table1.column = table2.column; |
RIGHT JOIN | Combine data from two tables, including all rows from the right table | SELECT * FROM table1 RIGHT JOIN table2 ON table1.column = table2.column; |
FULL OUTER JOIN | Combine data from two tables, including all rows from both tables | SELECT * FROM table1 FULL OUTER JOIN table2 ON table1.column = table2.column; |
INNER JOIN | Combine data from two tables, including only matching rows | SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column; |
UNION | Combine the results of two or more SELECT statements | SELECT column1 FROM table1 UNION SELECT column2 FROM table2; |
LIMIT | Limit the number of rows returned by a SELECT statement | SELECT * FROM table_name LIMIT number; |
| |
No comments:
Post a Comment
Tell us how you like it.