I have a SQL query set-up to display a list of entries based on the category ID found in the third segment, but I'm having a hell of a time trying to display the category name that goes along with it. This is what I have that's currently working:
SELECT
cd.field_id_19 AS song_number,
cd.field_id_20 AS song_title,
cd.field_id_21 AS song_artist
FROM exp_channel_data cd
LEFT JOIN exp_category_posts cp
ON cd.entry_id = cp.entry_id
WHERE cp.cat_id = {segment_3_category_id}
I know I have to add a JOIN with the exp_categories table in order for the exp_category_posts.cat_id to retrieve cat_name, but have not been successful in working it out.
Any help would be greatly appreciated.
cat_name
of the category onsegment_3
or of all categories of every entry?