<div class="article_title">
<span class="ico ico_type_Original"></span>
<h1>
<span class="link_title"><a href="/gaoweizang/article/details/52859449">
mysql(三):mysql查询语句 和 多表关联查询 以及 子查询
</a></span>
</h1>
1.查询一张表: select * from 表名;
2.查询指定字段:select 字段1,字段2,字段3....from 表名;
3.
where条件查询:select 字段1,字段2,字段3 frome 表名 where 条件表达式;
例:select * from t_studect where id=1;
select * from t_student where age>22;
4.带
in关键字查询:select 字段1,字段2 frome 表名 where 字段 [not]in(元素1,元素2);
例:select * from t_student where age in (21,23);
select * from t_student where age not in (21,23);
5.带
between and的范围查询:select 字段1,字段2 frome 表名 where 字段 [not]between 取值1 and 取值2;
例:select * frome t_student where age between 21 and 29;
select * frome t_student where age not between 21 and 29;
6.带
like的模糊查询:select 字段1,字段2... frome 表名 where 字段 [not] like '字符串';
“%”代表任意字符;
“_"代表单个字符;
例:select * frome t_student where stuName like '张三'';
select * frome t_student where stuName like '张三%'';
select * frome t_student where stuName like '%张三%'';//含有张三的任意字符
select * frome t_student where stuName like &#