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 join query

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-03-25 : 12:23:54
hi,

this is my db tables:

groupallocation
groupid(primarykey)
groupname

systemallocation

systemid(primarykey)
systemname

deviceallocation

deviceid(primarykey)
devicename
sensorallocation

sensorid(primarykey)
sensorname
groupid(foreignkey)
systemid(foreignkey)
deviceid(foreignkey)

so i want to make a query in sensorallocation table should display as like folllows:

i want to make query to join the tables and display the following fields.

sensorid,sensorname,groupname,systemname,devicename

becos in sensorallocation table i do have only groupid,systemid,deviceid only but while displaying i need to display groupname,systemname,devicename

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2008-03-25 : 12:46:24
sample data?
sample output?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL or How to sell Used Cars
For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-25 : 12:57:46
[code]Select
ra.sensorid, ra.sensorname, ga.groupname, sa.systemname, da.devicename
from sensorallocation ra join groupallocation ga
on ra.groupid = ga.groupid
join systemallocation sa on sa.systemid = ra.systemid
join deviceallocation da on da.deviceid = ra.deviceid[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2008-03-25 : 22:13:09
thank you harsh_athalye
Go to Top of Page
   

- Advertisement -