Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

287
Views
mysql json_extract dynamic position
SELECT id, JSON_EXTRACT(column,'$.parent[3].child') AS child FROM table 
WHERE JSON_EXTRACT(column,'$.parent[3].child') IN (1)

this is my sql query. i have a also column jsonlength how can i connect this 2 columns in one query ? i want to change 3 to dynamic number given in jsonlength

for example:

SELECT id, JSON_EXTRACT(column,'$.parent['jsonlength'].child') AS child FROM table 
WHERE JSON_EXTRACT(column,'$.parent['jsonlength'].child') IN (1)

but this query not working.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to form the JSON path with string concatenation. In MySQL, this is done with the CONCAT() function.

SELECT id, JSON_EXTRACT(column, CONCAT('$.parent[',jsonlength,'].child')) AS child FROM table 
WHERE JSON_EXTRACT(column,CONCAT('$.parent[',jsonlength,'].child')) IN (1)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!