表关联查询范例

$list = M("sanitation")->select();
$result = M("sanitation")
            ->join("sanitation_group on sanitation.san_group_id = sanitation_group.id")
            ->where($list["week"])
            ->field("sanitation_group.name,sanitation.id, sanitation.week,sanitation.time")
            ->select();
"sanitation"和"sanitation_group "为表名,"san_group_id "及其后的"id"分别为前面两表中字段,field中为查        

你可能感兴趣的:(表关联查询范例)