tp 子查询 sql 或框架查询方法
小白
2020-09-04
【原创文章】
tp 子查询 sql 或框架查询方法
tp 子查询 sql 或框架查询方法
$ss = 'select ObservTime,StationID from tc_autostation where StationID=\'TC001\' order by ObservTime desc limit 10'; $sql = 'select * from (select ObservTime,StationID from tc_autostation where StationID=\'TC001\' order by ObservTime desc limit 10) as tems where ObservTime=\'2019-12-11 10:00:00\''; $ifno = Db::query($sql); // return json(['where'=>$where,'or'=>$whereor]); $subQuery = Db::table('tc_autostation') ->field('StationID,RH,TT,ObservTime,status,InsertTime') ->where($where) ->buildSql(); $subQuery2 = Db::table($subQuery . ' a') // ->where('a.ObservTime', '=', '2019-12-11 10:00:00') ->order('ObservTime', 'desc') ->limit($curr*$nums,$nums) ->buildSql(); $info = Db::table($subQuery2 . ' c') // ->where('a.ObservTime', '=', '2019-12-11 10:00:00') ->order('ObservTime', 'desc') ->limit($curr*$nums,$nums) ->select();
最新发布

- 视频截取封面 =php-ffmpeg/php-ffmpeg!
- 常用实例2023-5-10!
- 富文本 塞入mysql 报错: General error: 1366 Incorrect string value: ‘\xF0\x9F\x98\x84‘ for column ‘content‘!
- 百度地图拖拽获取地址实例!
- php使用smtp鉴权方式发送邮件 插件PHPMailer!
- 有道翻译接口对接!
- tp5循环插入百万数据模块不存在:error!
- git 切换仓库版本!
- PHP通过OpenSSL生成证书、密钥并且加密解密数据,以及公钥,私钥和数字签名的理解!
- 微信支付jsapi v3支付实例!
最热排行
