A
A
Artem Kravchenko2016-08-01 11:03:40
MySQL
Artem Kravchenko, 2016-08-01 11:03:40

Why doesn't the LIKE condition work?

Hello. There is a standard Bitrix table with property values:

CREATE TABLE `b_iblock_element_right` (
  `IBLOCK_ID` INT(11) NOT NULL,
  `SECTION_ID` INT(11) NOT NULL,
  `ELEMENT_ID` INT(11) NOT NULL,
  `RIGHT_ID` INT(11) NOT NULL,
  `IS_INHERITED` CHAR(1) NOT NULL COLLATE 'utf8_unicode_ci',
  PRIMARY KEY (`RIGHT_ID`, `ELEMENT_ID`, `SECTION_ID`),
  INDEX `ix_b_iblock_element_right_1` (`ELEMENT_ID`, `IBLOCK_ID`),
  INDEX `ix_b_iblock_element_right_2` (`IBLOCK_ID`, `RIGHT_ID`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB;

If you run a query:
select * from b_iblock_element_property where IBLOCK_ELEMENT_ID = 1304566 AND `IBLOCK_PROPERTY_ID` = 740 AND `VALUE` = 'f830c4d1-9865-11e2-a058-00269e0aabeb'

d51e0c430458403db3cc8d7bac47baad.png
That normally is value in the table. But it is worth replacing = with LIKE:
select * from b_iblock_element_property where IBLOCK_ELEMENT_ID = 1304566 AND `IBLOCK_PROPERTY_ID` = 740 AND `VALUE` LIKE 'f830c4d1-9865-11e2-a058-00269e0aabeb'

And the query results are empty.
e2fcbaf1059b4381a52c9eedc1a2c62f.png
Please tell me why this behavior?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Kravchenko, 2016-08-01
@lan143

The problem was solved: it turned out that in that record, there was a space at the end. Those. the value in the VALUE column looked like this: 'f830c4d1-9865-11e2-a058-00269e0aabeb '.

G
GMAX, 2016-09-03
@GMAX

You actually have a table with a description and a table to which requests were made - these are 2 different tables ... :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question