tblProjects is linked to tblPrCat with t1_id-columns in both tables.
tblCategories is linked to tblPrCat with t3_id-columns in both tables.
A project may have several categories.
tblProjects
t1_id
t1_name
tblPrCat
t1_id
t3_id
tblCategories
t3_id
t3_name
I’m trying to use a single SELECT-sentence to get the value of a project (or 10) AND get all the names of the categories corresponding to each project.
Is this possible in a single SELECT-sentence returning a single row per project but multiple categories?
You can try a query like this:
Note: you’ll see every category name associated with each project, but if there are more than one category per project, you’ll see what appear to be duplicate project names. Be ready to deal with this in your code.
Edit:
I had assumed (probably wrongly) that every project has at least one category. To ensure you also see project names with none, use this instead:
Edit:
To show each project only once, but show a summary of category names as a comma-separated list, use this: