I've got the following MySQL tables:
What I want to build is an SQL query that will return all distinct section_id values from the subscription table, along with each section's title, and the title/URL of the page in which each section resides.
I'm sure this has got to be possible with a single query, but I'm having trouble working out exactly what the syntax is.
Can someone help please? Cheers!
EDIT: Nevermind, got it in the end:
SELECT s.section_id AS section_id
, se.title AS section_title
, p.title AS page_title
, p.path AS page_url
FROM (subscription s)
INNER JOIN SECTION se ON s.section_id = se.id
INNER JOIN page p ON se.page_id = p.id
GROUP BY s.section_id