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.
| Author |
Topic |
|
mpooley
Starting Member
13 Posts |
Posted - 2010-09-16 : 11:36:32
|
| sqlserver express I need help please.I have 5 tables 'Room' 'roomsensor' 'reading' 'sensor' and 'zone' columnsroom has ID Title and Zone Roomsensor has ID roomID and sensorIDreading has ID Temperature roomsensorID readingDate and BoilerStatesensor has ID Title and Offsetzone has ID and Titleone query has me stumped as it's returning multiple copies of the same dataI have a stored procedure with roomID , startdate and endate parametersand a simpler one with no params both give multiplesthis is the simpler one SELECT r.ID, r.Temperature, r.ReadingDate, rm.Title AS 'RoomName', r.BoilerState FROM Reading r JOIN RoomSensor rs ON r.RoomSensorID = rs.ID JOIN Room rm ON rs.RoomID = rm.ID ORDER BY r.ReadingDate ASC could anybody have a look and tell me what I am doing wrong please?MikeMichael D Pooley |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-16 : 11:43:03
|
| You are having multiple readings for a RoomSensor in Reading table. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-16 : 11:44:33
|
It is about your data.When you are joining tables and in one table there multiple rows for a joining condition then the select gives multiple rows in the result.That's normal.Since I don't know anything about your data in the tables this all I can say. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|