求教联合查询

浏览:517 发布日期:2016/01/10 分类:求助交流
生成的sql语句能正确执行,但tp页面却提示语法错误。

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'left join jyme_goods_class b on a.pid=b.id WHERE ( b.name = 'Glazed Tiles' )' at line 1 [ SQL语句 ] : SELECT a.name,b.name as pname FROM jyme_goods_class a left join jyme_goods_class b on a.pid=b.id WHERE ( b.name = 'Glazed Tiles' )

我是这样写的:
$c = M('goods_class');
$pclass=$this->_param('goods_class');
$where['b.name']=$pclass;
$prolist=$c->field('a.name,b.name as pname')->alias('a')->join('left join '.C('DB_PREFIX').'goods_class b on a.pid=b.id')->where($where)->select();
最佳答案
评论( 相关
后面还有条评论,点击查看>>