Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

335
Vistas
mysql json_extract function search in all position
WHERE FIND_IN_SET(1, JSON_UNQUOTE(JSON_EXTRACT(mycolumn, '$.parent[0].child'))) > 0

this query is working

WHERE FIND_IN_SET(1, JSON_UNQUOTE(JSON_EXTRACT(mycolumn, '$.parent[*].child'))) > 0

this query is not working

but when i want to put * instead of 0 my query is not working. i want to search key in all positions. first query only shows "search key" equal to only first (0) json

this is my json in mysql column

{"parent":[ { "child":"1,3", "type":"" },{ "child":"36,41", "type":"1" },{ "child":"52", "type":"1" } ]}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use a solution like this:

SELECT * 
FROM table_name
WHERE FIND_IN_SET(1, REGEXP_REPLACE(JSON_EXTRACT(column_name, '$.parent[*].child'), '[\\[\\]\\" ]', '')) > 0

JSON_EXTRACT returns a single value or a JSON array with all found values. The JSON array is not valid to use on FIND_IN_SET. You first have to remove the [, ] and " to get the comma separated list of all found values.

You can also use JSON_SEARCH to solve this:

SELECT *
FROM table_name
WHERE JSON_SEARCH(column_name, 'one', '%,1,%', NULL, '$.parent[*].child') IS NOT NULL OR
  JSON_SEARCH(column_name, 'one', '1,%', NULL, '$.parent[*].child') IS NOT NULL OR
  JSON_SEARCH(column_name, 'one', '%,1', NULL, '$.parent[*].child') IS NOT NULL

demo on dbfiddle.uk

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda