From: "Rob Brooks"
> Well, we have this db with various ip address ranges and the country of > origin associated with each ... the format is: > > countryOfOrigin FromIP ToIP > --------------- ------ ---- > US some lower bound some upper bound > Canada some lower bound some upper bound > Etc... > > So the real statement would be: > > Select countryOfOrigin From IPRangeTable where targetIP between FromIP and > ToIP What about creating an index on both FromIP and ToIP and using a query like: SELECT `countryOfOrigin` FROM `IPRangeTable` WHERE `FromIp` <= targetIP AND `ToIP` >= targetIP; This way MySQL can use the index to search the record and only needs a single read on the table itself to fetch the countryOfOrigin. Regards, Jigal. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]