Just turn your subquery into another join....

SELECT C2.City, N.Distance
FROM Cities C
INNER JOIN Nbc N ON C.CityID = N.PrimaryCityID
INNER JOIN Cities C2 ON C2.cityID = N.CityID
WHERE C.City = 'Los Angeles'
AND N.Distance <20

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Graham Anderson <[EMAIL PROTECTED]> wrote on 04/01/2005 04:49:31 PM:

> 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/[EMAIL PROTECTED]
> >
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to