Skip to content

Instantly share code, notes, and snippets.

@rahuldadhich
Last active January 16, 2018 04:14
Show Gist options
  • Save rahuldadhich/26b25b1fce584d1f738beb497127ad58 to your computer and use it in GitHub Desktop.
Save rahuldadhich/26b25b1fce584d1f738beb497127ad58 to your computer and use it in GitHub Desktop.
MYSQL JSON methods
// compair date from JSON
WHERE updated > JSON_UNQUOTE(json_column->'$.JSON_KEY_NAME')
#####
// SAVE JSON value in UPDATE query
// when don't know either JSON key have set value or not?
UPDATE table SET table_col = JSON_SET(COALESCE(table_col, '{}'), '$.JSON_KEY_NAME', 'json_values')
#####
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment