I want to fetch data from three different table in sql database.
My scenario is like.
Name ID Rollno
ABC 001 101
DEF 002 102
XYZ 003 103
From three table MasterA , MasterB , MasterC I required the below result
NAME ID Class Section
ABC 101 C1 S1
ABC 101 C2 S2
ABC 101 S3
DEF 102 C3 S1
DEF 102 C2
Can you please explain the logic for the result?
If you simply join all 3 tables by the column "Name" you would get 1 * 2 * 3 = 6 times "ABC" in the result; but you want only 3 times ABC.
There seems to be a relation between MasterB and MasterC missing.
What ever you understood is correct. I want minimum number of rows containing all information from three table.
Like for ABC I want only 3 rows, I dont want 6 row.
There is Name is comman between all three table. There is no relation between MasterB and MasterC.
If you want any further detail let me know.