Hi,

I have the following DB with data:

Code:
CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `RngPrefix` varchar(10) NOT NULL,
  `StrRange` varchar(10) NOT NULL,
  `EndRange` varchar(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;

INSERT INTO `products` (`id`, `RngPrefix`, `StrRange`, `EndRange`) VALUES
(1, '', 'AA001', 'AA999'),
(2, '', '2h0001', '2h3333'),
(3, '', '95001', '97000'),
(5, '', '2005N', '9999N'),
(6, '', '2003DN', '5003DN'),
(7, '', '3002LM', '9002LM'),
(8, '', '0A', '9Z'),
(9, '', '458A', '5124A'),
(10, '', 'CC001', 'CC2000'),
(11, '', '29220002', '292201000'),
(12, '', 'N001', 'N200');
And I am running the following query:

Code:
SELECT * FROM products WHERE 'CC456' >= StrRange AND 'CC456' <= EndRange
Why its not returning record # 10 ? And if you search for CC111 or CC1111 then it returns record 10. Why ?
The above database has ranges in it and i need to search between those ranges. What will be the best way ?

Thanks.