1. The grammatical format of the query statement
Syntax format:
select 字段名1,字段名2,字段名3,... from 表名;
note:
(1) any of a SQL statement in English semicolon " ; " at the end
(2) SQL statements are not case sensitive
2. Examples of query statements
Create a new students data table
CREATE TABLE students(
id INT NOT NULL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
score INT(10),
class VARCHAR(255)
);
Insert the following data into the newly created students data table
INSERT INTO students VALUES
(1,'张小明',82,1),
(2,'李翠花',75,3),
(3,'王强平',90,4),
(4,'赵宝强',65,3),
(5,'邹华文',88,2),
(6,'杨坤华',98,1),
(7,'刘海明',56,4),
(8,'赵德明',45,2),
(9,'张嘉玲',100,3),
(10,'金亚蓉',79,2),
(11,'刘伟强',NULL,1),
(12,'柯炳超',0,3),
(13,'习明',59,2),
(14,'周_学',62,3);
The created students data table is shown in the figure below
Example 1: Query student's grades?
SELECT name,score FROM students;
Example 2: Query the result of multiplying all student scores by 10
SELECT name,score*10 FROM students;