webForumDet fria alternativet

Vad kan jag ha missat

2 svar · 133 visningar · startad av erka

erkaMedlem sedan dec. 19996 522 inlägg
#1

Hej. Jag har ett litet register med 50 stycken addresser, så fort jag försöker få ut något från tabellen CountryStates så kommer endast de addresser som har något i fältet stateId i tabellen distributors upp. Om jag skiter i att ta med tabellen CountryStates så får jag fram alla 50. Vad kan jag har gjort för fel i mina relationer, fält.

SELECT Distributors.DistId, Distributors.Countryname_ID, Distributors.Name, Distributors.Adress1, Distributors.Adress2, 
Distributors.StateId, Distributors.Zip, Distributors.City, CountryName.CountryName_ID, CountryName.CountryName_GB, 
CountryName.CountryCode, CountryStates.StateId, CountryStates.StateName, CountryStates.StateCode FROM Distributors INNER JOIN CountryName ON Distributors.Countryname_ID = CountryName.CountryName_ID INNER JOIN
CountryStates ON Distributors.StateId = CountryStates.StateId AND 
CountryName.CountryName_ID = CountryStates.CountryName_ID

------------------
Real mad hiphop flavaz kickin' it right from tha street without no FEAR, Yo !

[Redigerat av erka den 11 jan 2002]

LarsGMedlem sedan dec. 200012 464 inlägg
#2
SELECT Distributors.DistId, Distributors.Countryname_ID, Distributors.Name, Distributors.Adress1, Distributors.Adress2, 
Distributors.StateId, Distributors.Zip, Distributors.City, CountryName.CountryName_ID, CountryName.CountryName_GB, 
CountryName.CountryCode, CountryStates.StateId, CountryStates.StateName, CountryStates.StateCode FROM Distributors inner JOIN CountryName ON Distributors.Countryname_ID = CountryName.CountryName_ID [b]left outer[/b] JOIN
CountryStates ON Distributors.StateId = CountryStates.StateId AND 
CountryName.CountryName_ID = CountryStates.CountryName_ID

så borde du få med även de där ststeid inte är satt.

------------------
essentitia preter non sans multiplicandum

erkaMedlem sedan dec. 19996 522 inlägg
#3

Tack lars g !

------------------
Real mad hiphop flavaz kickin' it right from tha street without no FEAR, Yo !

136 ms totalt · 3 externa anrop · v20260731065814-full.fb544a5a
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
134 ms — hämta tråd, inlägg och bilagor (db)