Blogger Information
Blog 35
fans 0
comment 0
visits 16728
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
mysql语句练习
手机用户311660634
Original
868 people have browsed it
  1. // empty 没有值,返回1,有值返回0
  2. $user = Db::table('oyk_user')->where('uid',16)->select();
  3. if($user->isEmpty()) {
  4. }
  5. // =, <> !=,> >=
  6. $user = Db::table('oyk_user')->where('uid','>','6')->select();
  7. // like模糊查询,%代表有多个不确定位置的值,_代表只有一个不确定的值
  8. // 前面加not,就是取反
  9. $user = Db::table('oyk_user')->where('nickname','like','小编%')->select();
  10. // between区间查询
  11. $user = Db::table('oyk_user')->where('uid','between','5,13')->select();
  12. // 指定查询 in
  13. $user = Db::table('oyk_user')->where('uid','in','1,3,5')->select();
  14. // table和name都是表明,name不带前缀
  15. $user = Db::table('oyk_user')->select();
  16. $user = Db::name('oyk_user')->select();
  17. // 排序用order,原生中是order by asc 正序,desc是倒叙
  18. $user = Db::table('oyk_user')->order('id desc')->select();
  19. // 翻页,获取条数,limit,1个参数代表获取多少条。2个参数代表从第几条到第几条
  20. $user = Db::table('shop')->limit(0,5)->select()->toArray();
  21. // 翻页进阶版,用page,第一个参数是当前页数,第二个参数是一次获取多少条
  22. $user = Db::table('shop')->page(2,5)->select()->toArray();
  23. // 聚合查询
  24. $user = Db::table('shop')
  25. ->field('id','title','img')
  26. ->where('id','>','6')
  27. ->order('id ASC')
  28. ->select()
  29. ->toArray();
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post