List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:April 1 2005 9:59pm
Subject:Re: Newbie: MYSQL nested query question
View as plain text  
What was wrong with Graham's simpler query?

PB

-----

Graham Anderson wrote:

> I upgraded my local mysql version to 4.1.10a and the below query 
> finally works :)
>
> How can I now amend the query so it works on my remote server running 
> mysql 3.23.58 ? From one headache to another ;)
>
> SELECT (
>
> SELECT City
> FROM Cities
> WHERE CityID = N.CityID
> ), N.Distance
> FROM Cities C
> JOIN Nbc N ON C.CityID = N.PrimaryCityID
> WHERE C.City = 'Los Angeles'
> AND N.Distance <20
>
> many many thanks to all those that replied :)
>
> g
>
> On Mar 31, 2005, at 11:49 PM, Philip M. Gollucci wrote:
>
>> 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
>>
>>
>>
>> -- 
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>>
>
>


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.1 - Release Date: 4/1/2005

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