-- tested with MySQL 5.7, MariaDB 10.2, PostgreSQL 9.4 select JSON_OBJECT( "name", name, "date", date, "timestamp", timestamp, "status", status, "price", price ) as json_format from history limit 1;
json_format |
---|
{"date": "2015-01-01 00:00:00.000000", "name": "foo", "price": 220.130140, "status": 5, "timestamp": 1420066800} |