2

How to search in array of objects in mysql using JSON_EXTRACT ?

Here is the data json

[
  {
    "prd_type": "stand_alone",
    "prd_unitprice": 70
  },
  {
  
    "prd_type": "stand_alone",
    "prd_unitprice": 50,
  }
]

and here is my query, this query works if there is only one object in array, it ignores second object in search

 SELECT  id,order_detail
     FROM member_transactions WHERE JSON_EXTRACT(order_detail, "$[*].prd_unitprice") < JSON_ARRAY(60);

the above query will not fetch record from second object of array

mobeen
  • 158
  • 1
  • 10
  • 1
    Checkin in late; Can you explain what's your issue since I get two records using this sample https://www.db-fiddle.com/f/cU9zdYErhfA9UVGwSiTErd/0 – wp78de Nov 11 '20 at 20:38
  • Apparently its only checking for the 1st object in the list of object. Even though the second object value satisfy the condition Any help would be appreciated on the same – bpetlur Jun 16 '21 at 13:12

0 Answers0