Question : Get all realted downloads to a subcategory

Below is some SQL from a system which gets all related categories for a given document (downloads)

I now wish to show what downloads each subcategory has related to it, so it should be  a  query like below but in reverse right based on the bps_id

could someone show me how? thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
this is a query used on the downloads page which gets all subcats each download is realted to....
 
SELECT bpdc.*,bpc.bpc_name, bps.bps_name
    FROM dbo.tbl_module_best_practice_downloads_categories bpdc
    LEFT JOIN dbo.tbl_module_best_practice_categories bpc ON bpc.bpc_id = bpdc.bpdc_category_id
    LEFT JOIN dbo.tbl_module_best_practice_subcategories bps ON bps.bps_id = bpdc.bpdc_subcategory_id
  	WHERE bpdc_deleted = 0
	AND	bpdc.bpdc_download_id = 
	ORDER BY bpc.bpc_rank, bps.bps_rank
 
This query gets all subcats...
		select		*
		from		tbl_module_best_practice_subcategories bps
		left join	tbl_admin_user AU on bps.bps_last_edited_by = AU.au_id
		
		
		where		bps.bps_id = 
		and			bps.bps_deleted = 0;
		
		where		bps.bps_deleted = 0
		order by	bps.bps_rank;
 
 
I now need one which gets all downloads related to each subcat....
 
?

Answer : Get all realted downloads to a subcategory

as I understant this shold do what you want...

SELECT bpdc.*,bpc.bpc_name, bps.bps_name
    FROM dbo.tbl_module_best_practice_downloads_categories bpdc
    INNER JOIN dbo.tbl_module_best_practice_subcategories bps ON bps.bps_id = bpdc.bpdc_subcategory_id
    LEFT JOIN dbo.tbl_module_best_practice_categories bpc ON bpc.bpc_id = bpdc.bpdc_category_id
WHERE bpdc_deleted = 0
  AND bps.bps_id = >
ORDER BY bpc.bpc_rank, bps.bps_rank
Random Solutions  
 
programming4us programming4us