Hi
I have a tracking table that logs ip addresses and the numerical equivalent of the ip address. I need to run a report that joins the tracking table to a lead conversions table and also looks up the country of each record from its numerical ip address.
I can perform a joined select query and then perform another select lookup query for each record from the country/ip mapping table, however this would result in 100's of query per report.
I think a single sub query would solve this database overload, but I cannot get it to work. I'm using MySQL v 4.1.21
The tables involved are tracking, conversions and ipcountry (which holds the ip vs country code data)
Every tracking record must be displayed whether or not an entry can be found in the ipcountry table.
This is the query that isn't working:
SELECT tracking.*, conversions.lead_type, conversions.posted, (ipcountry.countryshort WHERE tracking.ip_number BETWEEN ipcountry.ipfrom AND ipcountry.ipto as countryshort ) FROM tracking LEFT JOIN conversions ON tracking.id=conversions.track_id WHERE month='Jan' AND year = '07' ORDER BY rec_timestamp DESC LIMIT 0, 800
Any ideas gratefully received
Thanks