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 |
statix
Starting Member
12 Posts |
Posted - 2013-01-31 : 18:58:34
|
i try to normal few tables database i hope this code isnt complete mess im not brilliant with sql so dont be harsh with the comments.. SELECT DISTINCT state.state_id , county.county_id , city.city_idFROM state,county,city,datazipWHERE state.state_name=datazip AND county.county_name=datazip.county_name city.city_name=datazip.city_nameINTO state county city |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2013-01-31 : 19:31:20
|
[CODE]SELECT DISTINCT state.state_id , county.county_id , city.city_idFROM state,county,city,datazipWHERE state.state_name=datazip Missing .column name AND county.county_name=datazip.county_name Missing AND city.city_name=datazip.city_nameINTO state county city -- Not sure what you are trying to do here. Assign into variables??[/CODE]=================================================There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber |
|
|
statix
Starting Member
12 Posts |
Posted - 2013-01-31 : 19:38:39
|
here i fixed it abit while refreshing this page SELECT DISTINCT states.state_id, county.county_id, city.city_idFROM states CROSS JOIN county CROSS JOIN cityWHERE (county.county_name = datazip.county) AND (city.city_name = datazip.city) AND (states.state_name = datazip.state) but i still got errors with datazip.state its says "the multi-part identifier "datazip.city" could not be boundthanks in advance for any kind of help...! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-02-01 : 02:57:53
|
i think what you need is thisSELECT DISTINCT s.state_id , c.county_id , ct.city_idFROM datazip dINNER JOIN state sON s.state_name= d.stateINNER JOIN county cON c.county_name = d.countyINNER JOIN city ctON ct.city_name = d.city ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|