mysql2

xiaoxiao2021-02-28  27

表格:

选择查询:

select 字段 from 表名;

select id,name from students;

 

 

消除重复行:

select distinct 字段 from students;

select distinct gender from student;

查询 where的使用:

where是筛选行,select是筛选列

select 字段 from 表 where 条件;

select gender from students where gender = 0 ;

 

 

having和where 有时候可以互换,例如:

select gender from students having gender = 1;

 

 

但是,如果同时用where和having,having需要排在where后面,having是对筛选出的结果集再进行筛选,例如:

select name from students where gender = 1 having name='xiaohua';

 

 

 

转载请注明原文地址: https://www.6miu.com/read-1450171.html

最新回复(0)