So I have been using data mapper classes to handle database transactions for my current application and when I need to join I generally have a subclass. This time, I need to join 4 tables.
Anyone have any theories on how to accomplish this?
Here is my query I need to break down.
SELECT `i`.`imageName` FROM `mod_listings_images` AS `i`
INNER JOIN `mod_listings` AS `l` ON `i`.`listingId` = `l`.`listingId`
RIGHT JOIN `mod_listings_categories` AS `lc` ON `lc`.`listingId` = `l`.`listingId`
INNER JOIN `mod_categories` AS `c` ON `lc`.`categoryId` = `c`.`categoryId`
WHERE `i`.`imageWeight` = 0
GROUP BY `c`.`categoryId`
ORDER BY `c`.`categoryName` ASC, `l`.`listingCreation` DESC
It is to select an image from a listing that is associated with a category.