Skip to content
Advertisement

find exact number in text field in sql

I am trying to query exact number in array inside text field in sql so for example

SELECT tbl_campaigns.s_id,a_list_fk_i_id_tbl_affiliates
FROM tbl_campaigns
WHERE a_list_fk_i_id_tbl_affiliates LIKE '%1%'

can return

[3,8,7,11]

which is not good because i would like to get the arrays that contain 1

Advertisement

Answer

You could use JSON functions:

SELECT s_id,a_list_fk_i_id_tbl_affiliates 
FROM tbl_campaigns
WHERE JSON_CONTAINS(a_list_fk_i_id_tbl_affiliates, 1)
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement