(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();
没有串联起来
就写原生的吧 效率还高点 用query()方法