想请教一个关于left join重复的问题

2016-07-07 15:06 来源:www.chinab4c.com 作者:ecshop专家

小弟因为在功能上的需要,所以想自行做一下小的二次开发,可是不管怎么弄还是还是会有重复的值。


$sql = 'SELECT DISTINCT(mp.goods_id),g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
"g.promote_price, g.goods_type, " .
'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ,mp.activity_name , mp.ID ' .
'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('activity') . ' AS mp ' .
"ON mp.goods_id= g.goods_id" .
"WHERE $where AND mp.goods_id= g.goods_id$ext ORDER BY $sort $order";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);



其中mp.goods_id不唯一值
小弟真是新手,实在是搞不写,请各位帮个忙。谢谢