请问在ThinkPHP中如何实现下面这条SQL语句的连贯操作?
SELECTMAX(ap.step)max_step,yt.yacht_name,tk.*FROMpt_takeon_requestastkLEFTJOINpt_appr...
SELECT MAX(ap.step) max_step, yt.yacht_name, tk.* FROM pt_takeon_request as tk
LEFT JOIN pt_approve as ap on ap.request_id = tk.toid
LEFT JOIN pt_yacht as yt on yt.yid = tk.yid
WHERE ap.type = 'TakeOn' AND ap.`status` = 1
GROUP BY ap.request_id HAVING MAX(ap.step) > 0; 展开
LEFT JOIN pt_approve as ap on ap.request_id = tk.toid
LEFT JOIN pt_yacht as yt on yt.yid = tk.yid
WHERE ap.type = 'TakeOn' AND ap.`status` = 1
GROUP BY ap.request_id HAVING MAX(ap.step) > 0; 展开
1个回答
2016-10-06
展开全部
$model->filed(“MAX(ap.step) max_step, yt.yacht_name, tk.*“)->alias("tk")->join("LEFT JOIN pt_approve as ap on ap.request_id = tk.toid LEFT JOIN pt_yacht as yt on yt.yid = tk.yid")->where("ap.type = 'TakeOn' AND ap.`status` = 1")->group(ap.request_id HAVING MAX(ap.step) > 0)->select();
你语句没问题的话,大致就是这样。如果有错,就打印上一条语句。$model->getLastSql();
你语句没问题的话,大致就是这样。如果有错,就打印上一条语句。$model->getLastSql();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询