Skip to content
Advertisement

SQL Insert JSON into table column

while searching for a way to insert array into single db columns, I found an article about inserting JSON string. However it wasn’t explained how. I tried to search and find the way with no success.

I have the following table:

What i want to do is insert a Json arry in the address column. like:

I thought about inserting the JSON as String but im not sure if this a good idea. Any suggestions?

Advertisement

Answer

You can pass your data as a string, as long as it is valid JSON; MySQL will happily convert it for you under the hood.

An alternative is to use JSON builder functions:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement