The document outlines various SQL commands and their functions, including filtering, selecting, deleting, and modifying data in a database. It provides examples for each command, such as SELECT, INSERT INTO, UPDATE, and DELETE, along with aggregate functions like COUNT, MAX, MIN, SUM, and AVG. Additionally, it explains the use of constraints like PRIMARY KEY and FOREIGN KEY in table creation.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views2 pages
Tin Mysql
The document outlines various SQL commands and their functions, including filtering, selecting, deleting, and modifying data in a database. It provides examples for each command, such as SELECT, INSERT INTO, UPDATE, and DELETE, along with aggregate functions like COUNT, MAX, MIN, SUM, and AVG. Additionally, it explains the use of constraints like PRIMARY KEY and FOREIGN KEY in table creation.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Group Keyword Description Examples
WHERE Filters a result set to include
only records that fulfill a specified condition SELECT Selects data from a database SELECT DISTINCT Country F + DISTINCT + Selects only distinct (different) ROM Customers; values DELETE Deletes rows from a table DELETE FROM Table_name WH ERE Column_name = 'value1'; ALTER TABLE Adds, deletes, or modifies ALTER TABLE Table_name columns in a table - ADD Column_name ADD Adds a column in an existing varchar(255); table - DROP COLUMN ContactN DROP Deletes a column, constraint, ame; database, index, table, or view UPDATE Updates existing rows in a table UPDATE Customers SET ContactName='Juan' WHERE Country='Mexico'; INSERT INTO Inserts new rows in a table + INSERT INTO Customers + VALUES Specifies the values of an INSERT (CustomerName) INTO statement VALUES ('Cardinal'); WHERE + LIKE SELECT * FROM Customers COMMAND Searches for a specified pattern WHERE CustomerName LIKE + in a column -> Tìm kiếm 'a%'; CONDITION '%a'; '%or%'; 'a__%'; AND Only includes rows where both SELECT Column_name FROM T conditions is true able_name OR Includes rows where either - WHERE Country='value condition is true 1' AND City=' value2'; - WHERE Country='value 1' OR City=' value2'; BETWEEN Selects values within a given SELECT * FROM Products range WHERE Price BETWEEN 10 AN D 20; ORDER BY Sorts the result set in ascending SELECT Column_name(*/>1 - ASC or descending order columns) FROM Table_name - DESC - Sorts the result set in ORDER BY Column_muố n_xếp_ ascending order theo DESC(giảm)/ASC(tăng) - Sorts the result set in ; descending order CREAT CREATE Creates a new SQL database CREATE DATABASE DATA_name DATABASE ; CREATE Creates a new table in the CREATE TABLE Table_name ( TABLE database PersonID int, City varchar(255) ); KEY FOREIGN KEY A constraint that is a key used to CREATE TABLE Orders ( link two tables together FOREIGN KEY (PersonID) R EFERENCES Persons(PersonI D), PersonID int FOREIGN KEY REFERENCE S Persons(PersonID) ); PRIMARY KEY A constraint that uniquely CREATE TABLE Orders ( identifies each record in a PRIMARY KEY (OrderID), database table OrderID int PRIMARY KEY ); AGGREGATE GROUP BY Groups the result set (used with SELECT AGGREGATE_FUNCTION FUNCTIONS aggregate functions) (column_name1), -> liệt kê số lượng khách hàng ở column_name2 mỗi quốc gia, được sắp xếp từ FROM Table_name cao xuống thấp. Tức là mỗi quốc GROUP BY column_name2 gia có bao nhiêu khách hàng, số ORDER BY COUNT(column_nam lượng khách hàng của mỗi quốc e1) DESC; gia gia xếp từ cao xuống thấp COUNT Returns the number of records SELECT AGGREGATE_FUNCTION returned by a select query (column_name) AS new_name MAX FROM Table_name; Returns the maximum value in a set of values SELECT column_name2, MIN(column_name1) MIN Returns the minimum value in a FROM Table_name set of values GROUP BY column_name2; SUM Calculates the sum of a set of values AVG Returns the average value of an expression