November 25, 2007 at 12:41 pm
Hi All,
Please help me in the sysntaxt of Inner join. I want to pull the data from multiple table (5 tables) using Join on the particular key. So, please help me in this issue.. its an urgent for me...
I will appreciate for your help...
Regards,
KP
November 26, 2007 at 12:49 am
hi !
You seems to be really new in Database. you can check on BOL for inner join syntax. but for your reference here is the syntax for Inner Join..
Select (either from table 1 Or table 2 )
From table1
INNER JOIN table2 table1.KeyID = table2.RefKeyID ( from table1)
November 26, 2007 at 4:32 am
If you're writting your syntax properly and not coming up with the result set you expect, there could be one of two problems.
1) You're using the wrong keys to join tables on
or
2) You started off with the wrong table.
Usually I start off with the biggest table or the table likely to have the most matching records. Think of INNER JOIN for more than 2 tables like a pyramid. Each JOIN (if done correctly) is going to narrow down the record set.
If not done correctly, you could potentially end up with multiple rows that are almost duplicates of each other.
Search the BOL Index for subjects "inner joins [SQL Server]" and "joins [SQL Server]". You'll want to understand all the JOIN types before you do any joining. This way you can properly troubleshoot any problems you're having with the JOIN operator.
November 26, 2007 at 4:37 am
I think this is very basic question. so do a search in google.
karthik
November 26, 2007 at 7:25 am
Thanks to you all,
Regards,
KP
July 1, 2015 at 3:18 am
Suppose we have three tables
Employee(Emp_code,Name,Dept_Code,Desig_Code,CityID)
Department(Dept_Code,Dept_Name)
Designation(Desig_Code,DesigName)
City(CityID,CityName)
Query :
Select Emp_code,Name,Dept_Name,DesigName,CityName from Employee inner join Department On Department.Dept_Code=Employee.Dept_Code inner join
Designation ON Designation.Desig_Code=Employee.Desig_Code inner join City ON City.CityID=Employee.CityID
Same for other table
July 1, 2015 at 3:24 am
Please note: 8 year old thread.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply