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();
最佳答案