不知道为什么SQL出错了,我在MYSQL里面查询SQL查询语句都正常的,放到PHP里就不能用了 10
php中不行$sql="selectga.people_num,ga.goods_id,ga.ext_info,(ga.people_num-tj.c)s,u.user_...
php中不行
$sql = "select ga.people_num ,ga.goods_id ,ga.ext_info ,(ga.people_num - tj.c) s ,u.user_name from ". $this->pre ."goods_activity ga ".
"LEFT JOIN ". $this->pre ."opengroup_user ou on ga.act_id = ou.group_id and ga.tz_id = ou.user_id".
"LEFT JOIN ". $this->pre ."users u on ga.tz_id = u.user_id".
"LEFT JOIN (select group_id g,count(*) c from ecs_opengroup_user a where a.is_pay = 1 GROUP BY group_id ) tj on ga.act_id = tj.g ".
"where ga.mx_id = 107 and ga.is_finished = 0 and ou.is_pay = 1";
$result = $this->query($sql);
mysql中可运行
select ga.people_num ,ga.goods_id ,ga.ext_info ,(ga.people_num - tj.c) s ,u.user_name from `ecs_goods_activity` ga
LEFT JOIN ecs_opengroup_user ou on ga.act_id = ou.group_id and ga.tz_id = ou.user_id
LEFT JOIN ecs_users u on ga.tz_id = u.user_id
LEFT JOIN (select group_id g,count(*) c from ecs_opengroup_user where is_pay = 1 GROUP BY group_id ) tj on ga.act_id = tj.g
where ga.mx_id = 107 and ga.is_finished = 0 and ou.is_pay = 1 展开
$sql = "select ga.people_num ,ga.goods_id ,ga.ext_info ,(ga.people_num - tj.c) s ,u.user_name from ". $this->pre ."goods_activity ga ".
"LEFT JOIN ". $this->pre ."opengroup_user ou on ga.act_id = ou.group_id and ga.tz_id = ou.user_id".
"LEFT JOIN ". $this->pre ."users u on ga.tz_id = u.user_id".
"LEFT JOIN (select group_id g,count(*) c from ecs_opengroup_user a where a.is_pay = 1 GROUP BY group_id ) tj on ga.act_id = tj.g ".
"where ga.mx_id = 107 and ga.is_finished = 0 and ou.is_pay = 1";
$result = $this->query($sql);
mysql中可运行
select ga.people_num ,ga.goods_id ,ga.ext_info ,(ga.people_num - tj.c) s ,u.user_name from `ecs_goods_activity` ga
LEFT JOIN ecs_opengroup_user ou on ga.act_id = ou.group_id and ga.tz_id = ou.user_id
LEFT JOIN ecs_users u on ga.tz_id = u.user_id
LEFT JOIN (select group_id g,count(*) c from ecs_opengroup_user where is_pay = 1 GROUP BY group_id ) tj on ga.act_id = tj.g
where ga.mx_id = 107 and ga.is_finished = 0 and ou.is_pay = 1 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询