这个sql语句用thinkphp3.1.2的语法怎么串联在一起?
高洛峰
高洛峰 2017-04-11 10:31:23
[PHP讨论组]
(select a.log_id,create_date,content,creator,belong_to_user,a.customer_code,follow_up_way from gs_log a left join gs_customer b on a.customer_code=b.customer_code where b.customer_id='35926') union (select a.log_id,create_date,content,creator,belong_to_user,('') as customer_code,follow_up_way from gs_log a left join gs_r_customer_log b on a.log_id=b.log_id where b.customer_id='35926') limit 5,5

我写的:

 $log_join = "left join __CUSTOMER__ b  on a.customer_code = b.customer_code";
            $log_data = M('log')->alias('a')->where("b.customer_code != '' AND b.customer_id = $customer_id")->join
                ($log_join)->field("a.log_id,create_date,content,creator,belong_to_user,a.customer_code,follow_up_way")
                ->union("SELECT a.log_id,create_date,content,creator,belong_to_user,a.customer_code,follow_up_way FROM gs_log a left join gs_customer b on a.customer_code = b.customer_code WHERE ( b.customer_code != '' AND b.customer_id = $customer_id )")
                ->select();

没有串联起来

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(1)
迷茫

就写原生的吧 效率还高点 用query()方法

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号