Tables (table)
Column (COLOMN)
Rows (Row)
Primary key (primary key)
The row that uniquely identifies each row in the table is called the primary key. The values in the primary key column are not allowed to be modified or updated.
Sql:
Structured query Language, structured querying language.
Case insensitive. For readability, the SQL keyword is capitalized, with all columns and table names lowercase.
Whitespace is ignored, so SQL can be divided into many rows.
SELECT
Retrieving data
SELECT prod_id, Prod_name, Prod_price from Products ; -- Use the SELECT statement to select data from table products, specify 3 column names, and separate the column names with commas.
Output:
prod_id prod_name prod_price---------------------------------------------------- BNBG01 Fish bean bag toy 3.4900
...
The FROM keyword indicates the name of the table from which the data is retrieved.
Sort Retrieve data
Clauses (clause) are usually made up of a keyword and data.
ORDER by,
Order: The last clause in the SELECT statement should be guaranteed.
Sort multiple columns:
Sort the results first by two columns, first price, then name.
SELECT prod_id, Prod_price, Prod_name from Products ORDER by Prod_price, Prod_name;
Sort By column location:
SELECT prod_id, Prod_price, Prod_name from Products ORDER by 2,3;
Descending order:
ORDER by DESC
Ascending is the default.
Filtering data
WHERE
SQL must know