I created a table in MySQL:
DROP TABLE IF EXISTS `barcode`;
CREATE TABLE `barcode` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(40) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `barcode` VALUES ('1', 'abc');
INSERT INTO `barcode` VALUES ('2', 'abc ');
Then I request data from the barcode of the table:
SELECT * FROM barcode WHERE `code` = 'abc ';
Result:
+-----+-------+
| id | code |
+-----+-------+
| 1 | abc |
+-----+-------+
| 2 | abc |
+-----+-------+
But I want the result set to have only 1 record. I work around with:
SELECT * FROM barcode WHERE `code` = binary 'abc ';
The result is 1 record. But I use NHibernate with MySQL to generate a query from a mapping table. So how to solve this case?
source
share