During insert campaign, i am storing multiselected(checkbox List) events id stored using comma separated in campaign table. like 1,4,5,6
Now when i try to search campaign information based on these events ids, its not working proper . means when i try to search campaign by selecting event_id 1 ,it also search fields like 12,3,2 or 6,21,22 .
My search string is like following.
SELECT *
FROM `crm_campaign`
WHERE `event_ids` LIKE '%1,%'
OR `event_ids` LIKE '%,1,%'
OR `event_ids` LIKE '%,1%'
please give me suggestion.
should i change data structure for multiselect fields ?
Now i am inserting event_ids like ‘1’,’4′,’5′
Is it right approch ?
If Yes then then how to use search string in asp.net because these escape character gives me problem for mysqlcommand paramter.
Try concatenating commas to the start and end of
event_idsin the WHERE clause:Due to the nature of the table design, it will be slow if your table contains many rows.
If this becomes an issue, move the event ids into a separate related table.