Consider this QUERY (DEMO IS HERE)
(SELECT * FROM `titles` where title = 'test\\')
UNION ALL
(SELECT * FROM `titles` where title LIKE 'test\\\\')
Output:
| ID | TITLE |
--------------
| 1 | test\ |
| 1 | test\ |
QUESTION:
Why no extra (\) required for (=) but for (like) additional \\ is required? Its clear that MySQL escaped the (test\) with (test\\) then using (test\\\\) is logical for LIKE.
Table information:
CREATE TABLE IF NOT EXISTS `titles` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `titles`
--
INSERT INTO `titles` (`id`, `title`) VALUES
(1, 'test\\');
BINARY
comparison mode and you won't need the extra \\. sqlfiddle.com/#!2/b7284/8 (whoops link updated)