Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mdrathik's avatar

Search Query in Serialize data

Hi, I have multiple selected dropdown data_tags[] & I stored data_tags[] in the database as Serialize. Now I want to search in them by the same dropDown multiple selections. In this case, data should be fetched which has minimum one data.

or an example: Suppose I have a product named HTML with tag name LANGUAGE, and another product name is PHP with tag name LANGUAGE, PROGRAMMING LANGUAGE

$query = Produtcs::query()->with('Category','Status'); $query->where('data_tags', serialize($request->data_tags));

a:2:{i:0;s:2:"LANGUAGE";i:1;s:2:"PROGRAMMING LANGUAGE";}

Just need those row which row has a minimum one match

0 likes
1 reply
Braunson's avatar

Not sure why you are serializing it. Why not use json? Laravel support searching within json. If you need to search serialized data, you could try using like in the query but it's obviously not ideal.

Searching json columns using Eloquent (example):

 Products::query()->where('name->en','some text') 

Please or to participate in this conversation.