List:General Discussion« Previous MessageNext Message »
From:Philip M. Gollucci Date:April 1 2005 7:49am
Subject:Re: Newbie: MYSQL nested query question
View as plain text  
Graham Anderson wrote:
> What is the proper way to say this ?
> 
> SELECT C.City, N.Distance
> FROM Cities C
> JOIN Nearbycities N ON C.CityId =ci N.PrimaryCityId
> WHERE  N.CityId =
> (SELECT Cities.CityId FROM Cities WHERE Cities.city = 'Los Angeles')
> AND N.distance < 20
> 
> I am trying to enter in a city and get all the nearby cites with 20 miles
> Somehow, I need to join NearbyCities.PrimaryCityId, Cities.CityId, and 
> Cities.city
> 
> learning :)
> 
> 
Unless I missed something... Why did you make it so hard ?
SQL is meant to be easy :)

SELECT c.city, n.distance
FROM Cities c, Nearbycities n
WHERE c.cityid = n.primarycityid
AND c.city = 'Los Angeles'
AND n.distance < 20


Thread
Newbie: MYSQL nested query questionGraham Anderson1 Apr
  • Re: Newbie: MYSQL nested query questionPhilip M. Gollucci1 Apr
    • Re: Newbie: MYSQL nested query questionGraham Anderson1 Apr
      • Re: Newbie: MYSQL nested query questionPeter Brawley1 Apr
        • Re: Newbie: MYSQL nested query questionGraham Anderson2 Apr
          • Re: Newbie: MYSQL nested query questionGraham Anderson2 Apr
      • Re: Newbie: MYSQL nested query questionSGreen5 Apr