Having two tables, one of them is called Tasks and the other one Relations where every task in Tasks might have 0-to-many predecessors and similarly, 0-to-many successors that relations among tasks are stored in the Relations-table. So, if Task_1 is predecessor of Task_2 and Task_2 is predecessor of Task_3 then I would like to store the following records in the
Tag: many-to-many
Assign group_id to all linked records in many-to-many table
There are 3 tables in my DB; Table 1 has ‘Collateral’, Table 2 has ‘Loans’, Table 3 is a multi-link table between 1 and 2; let’s call it ‘Loan_Collateral_link’. A collateral can belong to 1 or more Loans, and a Loan can have multiple Collaterals. What I want to achieve, is create a separate result set (or table) in which
SQL- Get results based on four dependable tables with relations
I am trying to write sql query for a problem I am facing, but I can not get my head around it. I have team_member table with team_id and member_id. role table that stores roles with team_id (..name, slug) team_member_role table that is a many-to-many relationship between team_member and role (contains team_member_id and role_id). role_ability table, which stores role_id. (..action,
How do I use SQL to search a many to many relationship using AND
Can anyone help to create a SQL code which could list movies which have been searched under 2 or more tags for the tables below? E.g. I want to list all movies which have the tags “4star” AND “Drama”. Tables I have managed to create one which lists movies which have either one or another tag… thus. Which gives Star
Get distinct members for an array of group IDs
I have 3 tables: Scorecard Group Scorecard_Group (Joint table) I am trying to write a query that fulfills the following purpose: Get the list of distinct scorecard ids WHERE Scorecard_Group.groupId IN (Pass array of groupIds) Get all Scorecard.”name” where Scorecard.”id” IN (Array of scorecardIds that we just queries) I am able to achieve this using 2 queries but I would
How do I insert multiple rows with many to many relations into ‘Table1’ from ‘Table1’?
I’m trying to copy an existing ship, with all of its contents of its child tables (for lack of a better term) and their relations. So far I’ve got most of the copying down except for the ship’s tables that have a many to many relation. An example of my current situation is as follows: I have two individual tables
MySQL Filter on many-to-many on recipes – ingredients tables
In my application, I have 3 tables: recipes ingredients recipes_ingredients I need to find all those recipes that contain a list of ingredients_id and that I have in my food storage and containing NO OTHERS ids outside the list I provided (so not in my food storage). Example: i provide oil (id=111) bread=(id=222) result recipes: OK oil+bread OK bread OK
Find a record containing all or a part of a list of id of other table in a many-to-many relation on MySql/Jpa?
In my web application, I have 3 tables: TAB A: Recipes (id, name) TAB B: Recipes_Ingredients(id, fk_recipe,fk_ingredient, quantity) Bridge table TAB C: Ingredients (id, name) I need to find all the recipes(TAB A) that containing a provided list of ingredients (TAB C). Es: I provide a list of ingredients id like 111 (spaghetti), 222(pepper), 333(oil) and I need to find
Many-to-many relation Laravel Eloquent. Fetch related table with specific related id
I am writing a query in Laravel 8 using Eloquent. There is a many-to-many relation between subjects and streams and their pivot table is courses. subjects: id name streams id name courses id subject_id stream_id I have to fetch subjects with specific stream. I have written the following query. $this->subjects = Subject::has(‘streams’,$this->stream)->get(); I am having problem in this. courses table
Laravel many to many relastionship count
I have two tables. User and days, with many to many relationship. user_days : user_id, day_id I want to get the count number of users in day_id = 1 {for a particular day} or something like this. Any way to get count from pivot table? This function didnot work. the table structure ? How do I find the user count