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 |
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2009-04-24 : 10:18:18
|
| Hello friendsSELECT top 3 tb_features.feature_idFROM dbo.TB_Features, tb_propertiesWHERE county_display = 1 AND (feature_paid <> 1 or feature_paid is null) and tb_features.property_id = tb_properties.propertyid and tb_properties.prop_county = @thevalue ORDER BY NEWID()The above seems to duplicate the data numerous times which is really confusing me, what am I doing wrong? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-24 : 10:24:42
|
It depends on the JOIN.Try to add a DISTINCT keyword in your querySELECT TOP 3 tb_features.feature_idFROM dbo.TB_FeaturesINNER JOIN tb_properties ON tb_features.property_id = tb_properties.propertyidWHERE county_display = 1 AND (feature_paid <> 1 or feature_paid is null) tb_properties.prop_county = @thevalueORDER BY NEWID() E 12°55'05.63"N 56°04'39.26" |
 |
|
|
godspeedba
Yak Posting Veteran
90 Posts |
Posted - 2009-04-24 : 10:32:00
|
| ah I see now. Thanks very much Peso |
 |
|
|
|
|
|