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
G
strangely, the query works intermittently :(
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
sometimes it works...other times it gives the mysql query error:
show keys from
In the simple query...
the city field showed the result 'Los Angeles' in every row
the distance field showed incorrect results to :(
City| Distance
Los Angeles 18
Los Angeles 5
Los Angeles 7
...
On Apr 1, 2005, at 1:59 PM, Peter Brawle
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 Cit
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
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 a