TP的一条sql语句(子查询)

$model=M('');
$model->table(C('DB_PREFIX').'goods as g')
      ->join(C('DB_PREFIX').'orders as o on o.goods_id=g.id')
      ->where('o.user_id='.$userid.' and o.state=1 and o.id not in(select c.order_id from '.C('DB_PREFIX').'comment as c where c.user_id='.$userid.' and c.goods_id=g.id )')

 

posted @ 2014-05-29 18:06  天道酬勤,坚持!  阅读(4852)  评论(0编辑  收藏  举报