There is such a table
CREATE TABLE localhost.`regexp` ( id int(11) NOT NULL, name varchar(50) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE = INNODB AVG_ROW_LENGTH = 8192 CHARACTER SET utf8 COLLATE utf8_general_ci; The name field stores JSON in this form.
1|{"is_equal":["1","2","3"]} 2|{"is_equal":["3"],"is_not_equal":["2"]} We need help to create a request for data in which the name field contains in the is_equal key a value (either 1 or 2) for example.
Conditions:
1) MySql 5.6 is not possible to work as with JSON;
2) there is no possibility to change the subd;
3) I use PHP as a server language, but I want to do it on the base side;
4) it’s not worth talking about designing tables, historically, it’s impossible to change the structure;
At the moment there are:
SELECT * FROM localhost.`regexp` WHERE name REGEXP 'is_equal(1|2)' but he is looking for coincidences in is_equal and in is_not_equal , and I only need that in is_equal .
regexpWHERE name REGEXP 'is_equal (1 | 2)' but it looks for matches in both is_equal and is_not_equal, and I only need that in is_equal - InnerFlameis_equal(1|2)matches only two lines:is_equal1andis_equal2. Neither the first nor the second sample is not in the above JSON. This regular expression cannot match anything if you provided the correct data. Although, maybe I am mistaken in mysql some other interpretation of regular expressions, but it is unlikely. - ReinRaus