Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help needed in joing tables

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-04-02 : 02:37:11
hi,

i have a table(Measurement) with the following columns
SensorId,Maximumvalue,MinimumValue,GroupId,SystemId,DeviceId.

so in the above column SensorId is ForeignKey of the Table Sensor which havs two columns(SensorId,SensorName)

so in the above column GRoupId is ForeignKey of the Table Group which havs two columns(GroupId,GroupName)

SystemId is ForeignKey of the Table System which havs two columns(SystemId,SystemName)

DeviceId is ForeignKey of the Table Device which havs two columns(DeviceId,DeviceName)

so my result should be as like as follows:

SensorId,SensorName,Maximumvalue,MinimumValue,GroupName,SystemName,DeviceName.

instesd of displaysing GroupId, SystemId,DeviceId i need to diplay the SensorName,GroupName,SystemName,DeviceName. so please give me some example query to join multiple tables please

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-04-02 : 02:44:11
Select M.SensorId,S.SensorName,M.Maximumvalue,M.MinimumValue,G.GroupName,S1.SystemName,D.DeviceName
From Measurement M
INNER JOIN Sensor S on M.SensorId=S.SensorId
INNER JOIN Group G on M.GroupId=G.GroupId
INNER JOIN Device D on M.DeviceID=D.DeviceId
INNER JOIN System S1 on M.SystemID=S1.SystemID

Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-04-02 : 02:54:22
hi Prakash,

Thanks a lot for repy.
Go to Top of Page
   

- Advertisement -