[eluser]quasiperfect[/eluser]
hi
i have 3 tables and i need to get data from all 3 tables
for now i have the query
SELECT maxmind_locations.country,maxmind_locations.region,maxmind_locations.city FROM maxmind_cityblocks LEFT JOIN maxmind_locations ON maxmind_cityblocks.locId=maxmind_locations.locId WHERE 1449684273 BETWEEN maxmind_cityblocks.startIpNum AND maxmind_cityblocks.endIpNum
how can i modify the query to get maxmind_regions.name where maxmind_regions.code=maxmind_locations.region
can i do this in one query ?
the code for the tables is below
Code:
CREATE TABLE `maxmind_cityblocks` (
`startIpNum` int(10) unsigned NOT NULL,
`endIpNum` int(10) unsigned NOT NULL,
`locId` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
CREATE TABLE `maxmind_locations` (
`locId` int(10) unsigned NOT NULL,
`country` char(2) NOT NULL,
`region` char(2) DEFAULT NULL,
`city` varchar(50) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
CREATE TABLE `maxmind_regions` (
`country` char(2) NOT NULL,
`code` char(2) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8