1.查询某个表的所有数据

select * from 表名

2.查询某个表的指定列数据

select 列名1,列名2 from 表名

3.查询指定行的数据

select * from 表名 where 列名=\"条件\"

4.查询指定行,某几列的数据

查询列名1为条件1,并且列名2为条件2的数据

select 列名1,列名2 from 表名 where 列名1 = \"条件1\" and 列名2 = \"条件2\"

查询列名1为条件1,或列名2为条件2的数据

select 列名1,列名2 from 表名 where 列名1 = \"条件1\" or 列名2 = \"条件2\"

查询列名1为条件1,并且列名2不等于条件2的数据

select 列名1,列名2 from 表名 where 列名1 = \"条件1\" not 列名2 = \"条件2\"

5.查询某个表数据,根据城市ID顺序排列、账号倒序排列

select * from 表名 order by city_id asc, account desc

6.查询成绩表中,有哪些学生

select DISTINCT student_id from 表名

7.查询表中哪些行 为null

查询列名1为空的行
select * from 表名 列名1 is null

查询列名1不为空的行
select * from 表名 列名1 is not null

 

收藏 打印