Skip to content

Instantly share code, notes, and snippets.

@jagomf
Created June 7, 2020 20:30
Show Gist options
  • Save jagomf/f9481d928fe9fe62b2d441bfa9e17b2d to your computer and use it in GitHub Desktop.
Save jagomf/f9481d928fe9fe62b2d441bfa9e17b2d to your computer and use it in GitHub Desktop.
MySQL table to JSON
SELECT JSON_PRETTY(JSON_ARRAYAGG(
JSON_OBJECT('code', code, 'name', name, 'iso3', iso3, 'numcode', numcode, 'city', city)
)) FROM country;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment