your code worked when i added a left infront of the JOIN. This is what i have now and it works ok...not sure if the conversion i am making is the best way, seems to be a bit long...any ideas of making this shorter/less complex? Thanks
SELECT COUNT() AS country_hits, country
FROM ip_hits
left JOIN ip_country
ON (
SUBSTRING_INDEX(ip,'.',1) 256 256 256 + SUBSTRING_INDEX(SUBSTRING_INDEX(ip,'.',2),'.',-1) 256 256 + SUBSTRING_INDEX(SUBSTRING_INDEX(ip,'.',3),'.',-1) 256 + SUBSTRING_INDEX(ip,'.',-1) >= ip_from
AND
SUBSTRING_INDEX(ip,'.',1) 256 256 256 + SUBSTRING_INDEX(SUBSTRING_INDEX(ip,'.',2),'.',-1) 256 256 + SUBSTRING_INDEX(SUBSTRING_INDEX(ip,'.',3),'.',-1) * 256 + SUBSTRING_INDEX(ip,'.',-1) <= ip_to
)
GROUP BY country