Can't detect null value from JSON_EXTRACT

前端 未结 3 969
说谎
说谎 2020-12-11 15:10

I have a database that has an array of data stored in a JSON column. I need to find all values that have a null value at a particular position in the JSON array. While pulli

3条回答
  •  旧巷少年郎
    2020-12-11 15:49

    Well I had a suspicion but I found a workaround that confirms that a JSON null value is not the same as a MySQL null value.

    I tried various methods to get a similar null value but the only one that works is to extract a null JSON value from an array like the value I'm attempting to check against:

    SELECT JSON_EXTRACT(`COLUMNS_HEADERS`, '$[1]') , (JSON_EXTRACT(`COLUMNS_HEADERS`, '$[1]') = JSON_EXTRACT('[null]', '$[0]'))
    FROM ate.readings_columns_new;
    

    This seems like bad form, but was the only way I could get a value that evaluated as equal to the null values in my array.

提交回复
热议问题