E
E
Evgeny Shevtsov2016-03-07 17:14:47
PHP
Evgeny Shevtsov, 2016-03-07 17:14:47

How to find value in serialize array?

There is, for example, such an array in mysql
a:3:{i:0;s:1:"9";i:1;s:2:"12";i:2;s:2:"13";}
. Is it possible to somehow determine whether it contains the value '9' without converting it to a php array?
That is, at the select stage.
But you need to find exactly the value, because if there is something like that
a:3:{i:0;s:9:"11"}
and there is 9, this will not work.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melkij, 2016-03-07
@melkij

Bring data storage back to normal. And you will have a simple and quick search at the subd level.

L
LittleFatNinja, 2016-03-07
@LittleFatNinja

WHERE LOCATE('"5"', col) != 0

A
Alexander N++, 2016-03-08
@sanchezzzhak

better store data in JSON
mysql 5.6+ allows you to search for data by json
although there is an amusing option here
https://github.com/junamai2000/mysql_unserialize_php
not sure what works, it seems you need to compile this miracle as a plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question