Using MySQL MATCH to join case-insensitive column types

I use the MATCH condition to map to an int field and a varchar field. According to http://bugs.mysql.com/bug.php?id=22343 when mixing binary and non-binary column types, a match becomes binary and therefore case sensitive.

My question is, how can I make the search case insensitive? I tried using MATCH (below (a), b) VS ('title'), but this does not work.

Here is a circuit that can be used as a test.

CREATE TABLE IF NOT EXISTS `foo` (
  `a` int(11) NOT NULL,
  `b` varchar(50) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `foo` (`a`, `b`) VALUES
(2345345, 'title and volume'),
(145344, 'Volume'),
(1234214, 'Title');

SELECT * FROM `foo` WHERE MATCH (a,b) AGAINST ('title' IN BOOLEAN MODE)
+3
source share
1 answer

I think you have to do:

SELECT *
FROM `foo`
WHERE MATCH(`a`) AGAINST ('title' IN BOOLEAN MODE)
OR MATCH(`b`) AGAINST ('title' IN BOOLEAN MODE)
+2
source

Source: https://habr.com/ru/post/1714740/


All Articles