这篇文章主要为大家详细介绍了MySQL笔记之基本查询的应用分析,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
参考表:student
多字段查询
代码如下:
mysql> select id,name,birth from student;
代码如下:
mysql> select * from student;
代码如下:
mysql> select * from student where id=901;
mysql> select * from student where id>=904;
mysql> select name from student where department='计算机系';
代码如下:
mysql> select * from student where birth in(1988,1990);
mysql> select * from student where id in(903,906);
代码如下:
mysql> select * from student where birth not in(1990,1998);
代码如下:
mysql> select * from student where birth between 1986 and 1988;
代码如下:
mysql> select * from student where id not between 904 and 906;
代码如下:
mysql> select * from student where name like '_三';
mysql> select * from student where name like '张三';
mysql> select * from student where name like '张%';
代码如下:
mysql> select * from student where name not like '张%';
代码如下:
mysql> select * from student where address is null;
代码如下:
mysql> select * from student where name like '张%' and birth>1985;
mysql> select * from student where name like '张%' and birth>1985 and id like '%3';
代码如下:
mysql> select * from student where id=905 or birth=1988;
mysql> select * from student where id=905 or birth=1988 or sex='女';
distinct查询结果不重复
代码如下:
mysql> select distinct sex from student;
mysql> select distinct department from student;
代码如下:
mysql> select * from student order by birth;
mysql> select * from student order by birth asc;
mysql> select * from student order by birth desc;
代码如下:
mysql> select sex,group_concat(name) from student group by sex;
mysql> select sex,count(name) from student group by sex;
代码如下:
mysql> select * from student where birth regexp '1988|1990';
代码如下:
mysql> select * from student limit 2;
mysql> select * from student limit 1,3;
本文来自:http://www.q1010.com/177/9958-0.html
注:关于MySQL笔记之基本查询的应用分析的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:MYSQL
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。