What is best way to fetch data from two table with one to many relationship?

Jay Acharya

Here is table structure:

Table Task

id(PK) name
1      Task 1
2      Task 2

Table User

id(PK) name  
1     John Smith
2     Jack Will

Table Tasker

id(PK) taskId userId
1         1       1
2       1       2
3       2       1

Table task and user have one to many relationship by using Table tasker

ITWeiHan
select 
  T1.taskId,T1.userId,
  T2.name as User_name,
  T3.name as Task_name
from Tasker T1
left join User T2 on T1.userId = T2.ID
left join Task T3 on T1.taskId = T3.ID


SQL Fiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fetch data from two table that have one to many relationship in mysql?

What the best way to model a many to many relationship

select the relationship on one to many in two table joined

What is the best approach to mapping between two tables with one to many relationship?

Laravel one table connecting to two other by many to many relationship

The best way to model a one-to-many relationship in hibernate

Fetch data from many to many relationship with eloquent

What is the best way to separate out a few column from an existing table into a new table while maintaining relationship?

How to fetch data from one to many relationship using Django queries

best way to select data from one table or another

Fetching one to many relationship from same table

Laravel Eloquent - Fetch data only if there is a match with data one to many relationship

Best way to structure Core Data fetch for items, based on attribute(s) at other end of to-many relationship

Two way one to many relationship

What is the best way for selecting 2 row from table in one row?

What is the best way to fetch huge data from mysql with sqlalchemy?

What is the best way to pass data from one View to another in Xamarin?

What is the best way to fetch multiple stores (from server) at once, instead fetching them one by one?

What is the best way to map a Many to Many relationship in mongoose

What is the best way to model a one-to-many relationship that also has a "selected" object in Prisma?

what is the best way to select different data from same table in Laravel?

What is the optimized/best way to retrieve data from two tables?

Best way to handle updates for one-to-many relationship

Laravel Ajax fetch data one to many relationship

Laravel fetch intermediate table data with many to many relationship

Insert into a third table from two other tables with one to many relationship

What is the best way to model one-to-many relationship, when you cannot use embedded document in MongoDB?

Inserting data into one table of a many to many relationship and updating linking table

Hibernate + Spring Data Jpa: the best way to save entity with one-to-many relationship