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 |
akamole
Starting Member
17 Posts |
Posted - 2014-03-11 : 10:16:25
|
Hiselect adress.[Name] ,adress.NLocal AS 'Y' ,adress.ELocal AS 'X'from [sde_geofir_vansbroB].[gng].[READDRESS] adresswhere adress.[RealEstateID] in ( select a.RealEstateID from [sde_geofir_vansbroB].[gng].[READDRESS] a join [sde_geofir_vansbroB].[gng].[RETAXATIONUNIT] b on b.RealEstateID = a.RealEstateID where ( b.CodeType='220' or b.CodeType='221' or b.CodeType='222' ) )will return ~2800 rows.But i when i try to add following, it will return >1 million rows (or possibly go on forever, i press stop):select adress.[Name] ,adress.NLocal AS 'Y' ,adress.ELocal AS 'X' ,taxation.CodeTypefrom [sde_geofir_vansbroB].[gng].[READDRESS] adress, [sde_geofir_vansbroB].[gng].[RETAXATIONUNIT] taxationwhere adress.[RealEstateID] in ( select a.RealEstateID from [sde_geofir_vansbroB].[gng].[READDRESS] a join [sde_geofir_vansbroB].[gng].[RETAXATIONUNIT] b on b.RealEstateID = a.RealEstateID where ( b.CodeType='220' or b.CodeType='221' or b.CodeType='222' ) )Why??? Im only adding the column Codetype |
|
remyo
Starting Member
6 Posts |
Posted - 2014-03-11 : 10:32:09
|
You forgot to set the relationship between adress and taxationiefrom [sde_geofir_vansbroB].[gng].[READDRESS] adress, [sde_geofir_vansbroB].[gng].[RETAXATIONUNIT] taxationwhere adress.[RealEstateID] in(select a.RealEstateIDfrom [sde_geofir_vansbroB].[gng].[READDRESS] ajoin [sde_geofir_vansbroB].[gng].[RETAXATIONUNIT] bon b.RealEstateID = a.RealEstateIDwhere (b.CodeType='220'or b.CodeType='221'or b.CodeType='222')where adress.RealEstateID = taxation.RealEstateID) |
 |
|
|
|
|