不知道为什么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
展开
 我来答
直_销_库_网
2016-06-29 · TA获得超过614个赞
知道小有建树答主
回答量:443
采纳率:0%
帮助的人:168万
展开全部
把$sql打印出来看看和你在mysql里运行的是不是一样的就知道了。
希望可以帮到你
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式