让我们首先创建一个表-
create table DemoTable1837 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) );
使用插入命令在表中插入一些记录-
insert into DemoTable1837(StudentName) values('Chris'); insert into DemoTable1837(StudentName) values('David'); insert into DemoTable1837(StudentName) values('Bob'); insert into DemoTable1837(StudentName) values('Mike');
使用select语句显示表中的所有记录-
select * from DemoTable1837;
这将产生以下输出-
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 1 | Chris | | 2 | David | | 3 | Bob | | 4 | Mike | +-----------+-------------+ 4 rows in set (0.00 sec)
这是获取特定列记录的查询:
select StudentName from DemoTable1837;
这将产生以下输出-
+-------------+ | StudentName | +-------------+ | Chris | | David | | Bob | | Mike | +-------------+ 4 rows in set (0.00 sec)