考虑以下方案:
CREATE TABLE IF NOT EXISTS `test` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `test`
--
INSERT INTO `test` (`user_id`, `username`) VALUES
(1, 'Jason'),
(2, 'OOO'),
(3, 'Stack'),
(4, 'Overflow');
这个查询:
SELECT * FROM TEST WHERE username = 0
表明:
| USER_ID | USERNAME |
----------|----------|--
| 1 | Jason |
| 2 | OOO |
| 3 | Stack |
| 4 | Overflow |
但不是何时username = '0'
或何时username = 1