It's pretty difficult to pick a title, I'm sorry for that!
What I have for a database structure is the following columns:
pages
- id (int)
- url (string)
- content (string)
- created_at (timestamp)
groups
- id (int)
- related_page_ids (json)
- domain_id (int)
- created_at (timestamp)
What I want to achieve is to retrieve all groups by a selected domain ID and then retrieve all the related_pages with it. If I should write it in ugly PHP and MySQL:
$groups = SELECT * FROM groups WHERE domain_id = 1;
foreach($groups as $group){
$pages = SELECT * FROM pages WHERE IN id = implode($group['related_page_ids']);
}
I hope that you understand my goals with the ugly example.