Where clause for only one table in a left join

前端 未结 4 1467
难免孤独
难免孤独 2020-12-21 06:07

I have two tables, the first is \'actions\' which has columns \'id\' and \'actionname\', the second is \'completedactions\' which has \'userid\' and \'actionid\'. They look

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-21 06:30

    its will be help full if any body have need to use it.

    select `m`.`id` AS `id`,
    `m`.`CategoryParentId` AS `CategoryParentId`,
    `m`.`CategoryChildId` AS `CategoryChildId`,
    `p`.`CategoryName` AS `ParentCategory`,
    `c`.`CategoryName` AS `ChildCategory`,
    count(c_p.category_id) AS `prodcuts`,
    `img`.`image` AS `CategoryImage`,
    `img2`.`image` AS `thumbImage`
    from (((((`tblcategoryparentchildassociations` `m` 
        left join `tblmastercategories` `c` on((`c`.`id` =  `m`.`CategoryChildId`))) 
        left join `tblmastercategories` `p` on((`p`.`id` = `m`.`CategoryParentId`)))
        left join `vwimagetypeassociations` `img` on((`c`.`id` = `img`.`domainid` AND `img`.`imagetypeid` = 2 AND `img`.`status` = 1 )))
        left join `vwimagetypeassociations` `img2` on((`c`.`id`= `img`.`domainid`AND `img2`.`imagetypeid` = 3 AND `img`.`status` = 1)))
        left join `tblproductcategoriesassociations` `c_p` on((`m`.`CategoryChildId` = `c_p`.`category_id`)))
    group by m.id
    

提交回复
热议问题