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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Difficulty understanding difference

Author  Topic 

Quimbly
Starting Member

4 Posts

Posted - 2007-02-26 : 14:10:11
These queries don't return the same results. Can someone explain why?

SELECT LuminiareRegionStaticMapID, RegionStaticMapID, LuminaireID, XPosition, YPosition FROM dbo.LuminairesRegionStaticMap
where LuminaireID in (SELECT luminaireID from LuminairesRegionStaticMap where RegionStaticMapID = 11)


select LuminiareRegionStaticMapID, RegionStaticMapID, LuminaireID, XPosition, YPosition FROM dbo.LuminairesRegionStaticMap
where RegionStaticMapID = 11

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-26 : 14:33:18
First query matches on LuminaireID and second query matches on RegionStaticMap.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Quimbly
Starting Member

4 Posts

Posted - 2007-02-26 : 14:57:57
Ahh, I've discovered the answer myself.

The answer is, there is no difference, unless the LuminairesRegionStaticMap table has rows with duplicate LuminaireID values. Then, the first query returns those records with different values for RegionStaticMapID.

Go to Top of Page
   

- Advertisement -