Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey!

I want to say sorry right now because this question might become a little bit of a mess, english isn't my native language and I'm not used to formulating longer text's like this.

Alright, let's say I have 5 tables

Table 1

PKTable1 | FKTable3 | Quantity | Position


Table 2

PKTable2 | Date | Status | FKTable4 


Table 3

PKTable3 | ArticleName | Price


Table 4

PKTable4| Name | FirstName 


Table 5

PKTable5 | FKTable1 | FKTable2


Can I somehow fetch for example Name and FirstName from Table4 only using Table5?

I'm using C#, LinQ and EntityFramework if that helps

What I have tried:

This is more of a 'is this possible' question, rather than one directly related to code so I've nothing to show here sadly.
Posted
Updated 19-Apr-18 22:03pm
Comments
F-ES Sitecore 20-Apr-18 4:02am    
Not using only table5, you'll need table5 joined to table2 which is then joined to table4. Google how you join tables in entity framework as there are different ways depending on what coding style you use.

1 solution

Yes:
SQL
SELECT t4.Name, t4.FirstName FROM Table5 t5
JOIN Table2 t2 ON t5.FKTable2 = t2.PKTable2
JOIN Table4 t4 ON t4.PKTable4 = t2.FKTable4
Try it in SSMS and you'll see what it does.
Have a look at JOIN for an explanation: SQL Joins[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900