-3

Does not return rows from serialized data by using like operator

Select * from `transactions` where 'order_id' like "'%115%'"
Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
Rahul Jat
  • 656
  • 1
  • 7
  • 14

2 Answers2

2

Looking to your code you are trying to match not the coumn name but the string 'order_id' with the string "'%115%'" that, obviuosly , don't match so you have no rows result ..then

avoid single quote around column name and use concat for form a proper like condition

Select * from `transactions` where order_id like concat('%', '115', '%')

and be sure your order_id is string data type columns otherwise you should use

Select * from `transactions` where order_id =115
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
1

Use one of the following :

1) If your order_id field is integer and you want to get exact value try this

SELECT * FROM `transactions` WHERE order_id = 115

2) If your order_id field is integer and you want to get matching value try this

SELECT * FROM `transactions` WHERE CAST(order_id AS CHAR) LIKE '%115%'

3) If your order_id field is string and stored as serialized data try this

SELECT * FROM table WHERE field REGEXP '.*"array_key";s:[0-9]+:".array_value.".*'

ex. : SELECT * FROM `transactions` WHERE order_id REGEXP '.*"m5";s:[0-9]+:"115".*'

4) If your order_id field stored as simple string try this

SELECT * FROM `transactions` WHERE order_id LIKE '%115%'

I hope this will help you :)