search

Home  >  Q&A  >  body text

Access JSON columns

How do I access the values ​​stored as JSON in the status and date columns? Please see the example lines below.

{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03 -30 “}}

P粉345302753P粉345302753266 days ago467

reply all(1)I'll reply

  • P粉713846879

    P粉7138468792024-03-31 09:19:18

    Demo:

    set @j = '{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}';
    
    select json_extract(@j, '$."1".status') as status;
    +--------+
    | status |
    +--------+
    | true   |
    +--------+

    In this case, you might accidentally need to put double quotes around "1" to use it in a JSON path.

    reply
    0
  • Cancelreply