subrama6
subrama6

Reputation: 517

How do I use json_object in mysql to create objects whose values are dynamic?

I'm trying to create add a json object to a number of records where the value is a UUID. poking at it, i can limit the issue to this:

select json_object("uuid", select UUID())

even a basic

select json_object("uuid", select "1") doesn't seem to work

in both instances i get a syntax error on the subselect. does json_object not support having one of the parameters be the result of a mysql method? and/or is there a better way for me to do this? this is in MySql 5.7.12

Upvotes: 0

Views: 327

Answers (1)

Barmar
Barmar

Reputation: 781003

You don't need to nest SELECT. Just call the function.

SELECT JSON_OBJECT("uuid", UUID());

Upvotes: 2

Related Questions