SELECT 📥 Select data from a database table. It retrieves rows that match specified conditions.
Example:
"SELECT column1, column2 FROM table_name WHERE condition;"
Example:
"SELECT column1, column2 FROM table_name WHERE condition;"
INSERT 📤 Add new rows to a table.
Use "INSERT INTO table_name (column1, column2) VALUES (value1, value2);" to add data.
Use "INSERT INTO table_name (column1, column2) VALUES (value1, value2);" to add data.
UPDATE 🔧 Modify existing data in a table.
Syntax:
"UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;"
Syntax:
"UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;"
DELETE 🗑️ Remove specific rows from a table.
Usage:
"DELETE FROM table_name WHERE condition;"
Usage:
"DELETE FROM table_name WHERE condition;"
WHERE ❓ Filter records based on specified conditions. It follows the SELECT, UPDATE, or DELETE statement.
Example:
"SELECT * FROM table_name WHERE condition;"
Example:
"SELECT * FROM table_name WHERE condition;"
ORDER BY 📊 Sort query results in ascending or descending order.
Syntax:
"SELECT column1, column2 FROM table_name ORDER BY column1 ASC;"
Syntax:
"SELECT column1, column2 FROM table_name ORDER BY column1 ASC;"
GROUP BY 👥 Group rows with identical values in specified columns. Useful with aggregate functions like COUNT, SUM, etc.
Format:
"SELECT column1, COUNT(*) FROM table_name GROUP BY column1;"
Format:
"SELECT column1, COUNT(*) FROM table_name GROUP BY column1;"
JOIN ➕ Combine data from two or more tables based on a related column.
Common types: INNER, LEFT, RIGHT, FULL.
Example:
"SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;"
Common types: INNER, LEFT, RIGHT, FULL.
Example:
"SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;"
LIKE 🎯 Perform partial string matching in WHERE clauses. Use "%" as a wildcard.
Example:
"SELECT * FROM table_name WHERE column LIKE 'keyword%';"
Example:
"SELECT * FROM table_name WHERE column LIKE 'keyword%';"
IN ✔️ Check if a value matches any value in a list.
Example:
"SELECT * FROM table_name WHERE column IN (value1, value2, value3);"
Example:
"SELECT * FROM table_name WHERE column IN (value1, value2, value3);"
BETWEEN 🌈 Retrieve values within a specified range.
Format:
"SELECT * FROM table_name WHERE column BETWEEN value1 AND value2;"
Format:
"SELECT * FROM table_name WHERE column BETWEEN value1 AND value2;"
NULL 🚫 Identify NULL values in the database.
Use "IS NULL" or "IS NOT NULL" in WHERE clauses.
Use "IS NULL" or "IS NOT NULL" in WHERE clauses.
DISTINCT 🧊 Fetch unique values from a specific column.
Syntax:
"SELECT DISTINCT column FROM table_name;"
Syntax:
"SELECT DISTINCT column FROM table_name;"
HAVING 🕵️ Filter groups based on aggregate function results.
Example:
"SELECT column1, COUNT() FROM table_name GROUP BY column1 HAVING COUNT() > 5;"
Example:
"SELECT column1, COUNT() FROM table_name GROUP BY column1 HAVING COUNT() > 5;"
AS 🎭 Alias column names or table names. Improve readability.
Example:
"SELECT column1 AS alias_name FROM table_name;"
Example:
"SELECT column1 AS alias_name FROM table_name;"
UNION 🤝 Merge the results of multiple SELECT queries into a single result set.
Use "UNION" or "UNION ALL" to include duplicates.
Use "UNION" or "UNION ALL" to include duplicates.
CREATE TABLE 🗄️ Create a new database table.
Syntax:
"CREATE TABLE table_name (column1 datatype, column2 datatype, ...);"
Syntax:
"CREATE TABLE table_name (column1 datatype, column2 datatype, ...);"
ALTER TABLE 🔧 Modify an existing table structure.
For example, add new columns or change data types.
Syntax:
"ALTER TABLE table_name ADD column_name datatype;"
For example, add new columns or change data types.
Syntax:
"ALTER TABLE table_name ADD column_name datatype;"
DROP TABLE 💥 Delete a table and its data from the database. Use with caution!
Syntax:
"DROP TABLE table_name;"
Syntax:
"DROP TABLE table_name;"
TRUNCATE TABLE 🗑️ Remove all rows from a table without deleting the table structure.
Use "TRUNCATE TABLE table_name;" for quick deletion.
Use "TRUNCATE TABLE table_name;" for quick deletion.
COUNT 📈 COUNT is an aggregate function that counts the number of rows matching the specified condition.
Example:
"SELECT COUNT(*) FROM table_name WHERE condition;"
Example:
"SELECT COUNT(*) FROM table_name WHERE condition;"
AVG 🧮 AVG calculates the average value of a numeric column.
Usage:
"SELECT AVG(column) FROM table_name;"
Usage:
"SELECT AVG(column) FROM table_name;"
MAX ⬆️ MAX returns the maximum value from a column. It is used to find the highest value in a specific column.
Example:
"SELECT MAX(column) FROM table_name;"
Example:
"SELECT MAX(column) FROM table_name;"
MIN ⬇️ MIN returns the minimum value from a column. It helps find the lowest value in a specific column.
Syntax:
"SELECT MIN(column) FROM table_name;"
Syntax:
"SELECT MIN(column) FROM table_name;"
SUM ➕ SUM calculates the sum of values in a numeric column. It is used to get the total of a specific column.
Example:
"SELECT SUM(column) FROM table_name;"
Example:
"SELECT SUM(column) FROM table_name;"
Happy SQL-ing! 🚀📚 Keep mastering these commands to become a SQL pro!
If you need further assistance, feel free to ask! #SQL #Database #DataManipulation
If you need further assistance, feel free to ask! #SQL #Database #DataManipulation
Retweet the thread if you find it useful. Thanks!
جاري تحميل الاقتراحات...