First, the basic usage of the SELECT statement
SELECT statement will select the data in the database, stored in a results table.
SELECT syntax:
1 SELECT column names, column names 2 ... FROM table name;
Look at the student table:
1, the query specified column
Queries the student table 'student_number' and 'name' cases, for example:
SELECT student_number,name FROM student;
result:
2, all queries column
You can use an asterisk (*) to query all columns, for example:
SELECT * FROM student;
result:
Two, SELECT DISTINCT statement
SELECT DISTINCT used to return only difference values.
Syntax:
SELECT DISTINCT 1 column name, column name 2 ... FROM table name;
Student lookup table, 'class_id' column contains a value, for example:
SELECT DISTINCT class_id FROM student;
We can see class_id = '3' appears only once, the results: