现在的目的是要把article_category中的name字段导入到article中去
表yz_article如下
表yz_article_category如下
$article = M('article_category')
->join('yz_article On yz_article_category.id = yz_article.cate_id')->select();
粘贴其他几个案例里面的
$data = M("groups g")
->field('g.id,g.group_name,e.uid')
->join('left join equipment e ON g.group_name = e.group_name')
->where(array('g.user_id' => '1'))
->select();
$members=$model->table('zhope_card A')
->join('zhope_user U ON A.adduser=U.id',"LEFT")
->join('zhope_tpl T ON A.tpl=T.id')
->field('A.id AS I,A.cid AS Card_id,U.name AS Creator,T.name AS Tpl_name')
->select();
JOIN 默认采用LEFT JOIN 方式
左连接
$Model->join('LEFT JOIN work ON artist.id = work.artist_id')->select();
右连接
$Model->join('RIGHT JOIN work ON artist.id = work.artist_id')->select();
官方文档的说明