I tried the query your DBA gave you, it works, in that it returns all of the links for the category id associated to the given name in the where clause, but it doesn't return the links from categories that are grouped with that... Essentially it returns the same thing as this..
SELECT category_groups.group_id, categories.id, links.url, categories.name
FROM categories
INNER JOIN links ON categories.id = links.category_id
INNER JOIN category_groups ON categories.id = category_groups.category_id
WHERE categories.name = 'Testing' OR category_groups.group_id = category_groups.group_id
This works! adding the OR did it! I'm going to add in more data and test it with more categories grouped, see if that works... but it should.. I think, ha..
SELECT category_groups.group_id, categories.id, links.url, categories.name
FROM categories
INNER JOIN links ON categories.id = links.category_id
INNER JOIN category_groups ON categories.id = category_groups.category_id
WHERE categories.name = 'Testing' OR category_groups.group_id = category_groups.group_id
This works! adding the OR did it! I'm going to add in more data and test it with more categories grouped, see if that works... but it should.. I think, ha..
SELECT category_groups.group_id, categories.id, links.url, categories.name
FROM categories
INNER JOIN links ON categories.id = links.category_id
INNER JOIN category_groups ON categories.id = category_groups.category_id
WHERE categories.id
IN (
SELECT category_groups.category_id
FROM category_groups
WHERE category_groups.group_id = (
SELECT category_groups.group_id
FROM category_groups
INNER JOIN categories ON categories.id = category_groups.category_id
WHERE categories.name = 'Testing' )
)