0

I am trying to check if column contains string for example i have the following arrays;

['1','2']
['1']
['1','2','3']

I need to make an sql query to find if any of the arrays contains for example 1 so far i tried to use 'like' and 'in' but it doesn't seem to work

deals4us3
  • 35
  • 1
  • 4
  • why are you using sql? the database doesn't have any arrays in it, so they must be in your code. if you are actually wanting to look in a database column, show us what the data looks like in the database – ysth Oct 20 '20 at 07:08
  • Does this answer your question? [How to search JSON array in MySQL?](https://stackoverflow.com/questions/36249828/how-to-search-json-array-in-mysql) – Dark Knight Oct 20 '20 at 07:10
  • MySQL doesn't have arrays, so your question is unclear. – Gordon Linoff Oct 20 '20 at 12:27

2 Answers2

0

i don't know what your table or column names are but if those examples represent a single column data, like clause should be working;

  select * from TABLE where COLUMN like '%1%'
SnnG
  • 61
  • 5
0

You need to specify the index of the array where you are checking

    select * from TABLE where COLUMN[1] like '%1%'
rwangari
  • 1
  • 1