Hi, thanks for trying to helping me.
This is what returns:
Code:
SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESCSELECT `w`.*, `t2`.*, GROUP_CONCAT(c.category_slug order by c1.lvl desc SEPARATOR '/') AS cFullSlug, GROUP_CONCAT(c.category_name order by c1.lvl desc SEPARATOR '|') AS cFullName FROM `WS_closures` `c1` LEFT JOIN `WS_category` `c` ON `c`.`category_seq_id` = `c1`.`ancestor` LEFT JOIN `WS_category` `t2` ON `t2`.`category_seq_id` = `c1`.`descendant` LEFT JOIN (SELECT `wp`.`category_seq_id` as `wpcid`, `w`.* FROM `WS_wallpapers_path` `wp` JOIN `WS_wallpapers` `w` ON `w`.`wallpaper_seq_id` = `wp`.`wallpaper_seq_id` LEFT JOIN (SELECT `tv_views_count` as `total_views`, `tv_wid` as `wv_wid` FROM `WS_wallpapers_temp_views`) as v ON `v`.`wv_wid` = `w`.`wallpaper_seq_id` GROUP BY `wp`.`category_seq_id` ORDER BY `total_views` DESC) as w ON `w`.`wpcid` = `c`.`category_seq_id` WHERE `w`.`wallpaper_seq_id` IS NOT NULL GROUP BY `c1`.`descendant` ORDER BY `t2`.`category_name` ASC
And these are the tables involved:
table:
WS_wallpapers_path -> with this columns:
wp_seq_id wallpaper_seq_id category_seq_id
table:
WS_wallpapers -> with this columns:
wallpaper_seq_id wallpaper_name wallpaper_slug category_seq_id wallpaper_image_path
table:
WS_wallpapers -> with this columns:
category_seq_id category_slug category_name category_parent_id category_status
table:
WS_closures -> with this columns:
id ancestor descendant lvl
table:
WS_wallpapers_views -> with this columns:
wv_seq_id wv_date wv_ip wv_uid wv_wid