select all column from tables and put it in JSON_OBJECT

Viewed 105

I'm currently using JSON_OBJECT function to make JSON objects of few tables. So i use it like this :

SELECT JSON_OBJECT(
    "key1", key1,
    "key2", key2
)
FROM table1

But i have tables with more then 30 keys, and i need to write all keys, and all values (also, keys and values almost always have the same name)

So my question is the following : Is there a way to say to MySQL to select all column, and put it in the JSON_OBJECT ? Writing all keys / values is in fact a best practices, but with tables with more then 30 columns it's pretty time consuming.

0 Answers
Related