My study notes, the records are my own thought of the knowledge point, may later look at the time to turn the book, but can be used to locate the exact book of the location of the sample, reduce the time to find the book again, conducive to the construction of their own knowledge system. Self-Transcendence
5th Chapter Basic Query operation
5.1 Querying all columns of records
Select distinct * FROM table name, view name
* represents all columns, from which you can have up to 256 tables or view names, separated by ",".
* location can be replaced with field names, multiple field names with "," separated, several field names to check a few columns.
Distinct keyword, which is used to remove duplicate row data when the specified column is checked. (primary key is always different, * cannot be used)
The field name followed by as as gives the field an alias.
5.2 Arithmetic operations on the records of a query
You can use arithmetic operators to +-*/,*/precedence over +-in a SELECT statement.
Example: Check the teacher's annual income
Select teacher ID, teacher monthly income *12 as teacher annual income from teacher table
The operation in select does not change the original value, only changes the result of the query that is displayed.
5.3 Using Connectors | | Connection fields
Two fields can be used | | into a new string.
When connecting a field, the type of two fields should be the same, and if different, the system will have an error. If you need to include a character in a connected field or a value of a date type, you need to wrap the value of that character or a date type with single quotes.
MySQL and SQL Server do not support | | Select Student Name | | Teacher Name
MySQL uses the concat function select concat (student name, teacher name)
SQL Server uses the + number select Student Name + teacher Name