当前位置:Gxlcms > 数据库问题 > MySQL 学习

MySQL 学习

时间:2021-07-01 10:21:17 帮助过:2人阅读

limit 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 学习

标签:

人气教程排行