首页 > 数据库技术 > 详细

MySQL 学习

时间:2016-04-16 16:39:19      阅读:253      评论:0      收藏:0      [点我收藏+]

1、limit x,ylimit z  :选取从x开始的y条数据  或  选取最开始的 z条数据

select * from product limit 0,10
select * from product limit 10

 

2、like ‘%N%‘ : 模糊查询 查找出含有 ‘N’ 的数据

select * from product where product_name like %饼%

3、in (‘x‘,‘y‘) : 查询指定字段为x或者y的数据

select * from product where warehouse in (二院店,农夫店) 

4、between ‘x‘ and ‘y‘ :查询指定字段间于x,y之间的值 (这些值可以是数值、文本或者日期)

select * from storage where last_time between 1460937599 and 1460937601‘   /*在此范围的*/
select * from storage where last_time not between 1460937599 and 1460937601‘  /*不在此范围的*/

5、as : 组合查询 设置别名

select s.bar_code as bar_code,s.warehouse,s.num as stock,s.last_time,p.supplier from storage as s,product as p where s.bar_code = p.bar_code

6、join :与5相同的效果

select s.bar_code as bar_code,s.warehouse,s.num as stock,s.last_time,p.supplier from storage as s inner join product as p where s.bar_code = p.bar_code
  • JOIN: 如果表中有至少一个匹配,则返回行
  • LEFT JOIN: 即使右表中没有匹配,也从左表返回所有的行
  • RIGHT JOIN: 即使左表中没有匹配,也从右表返回所有的行
  • FULL JOIN: 只要其中一个表中存在匹配,就返回行

7、

 

MySQL 学习

原文:http://www.cnblogs.com/GaoAnLee/p/5398590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!