尝试从mysql workbench创建一个包含json_array的json_object。
以下语句导致“错误代码:1242。子查询返回多于1行”:
SELECT JSON_OBJECT('id', id,
'username', username,
'email', email,
'firstname', firstname,
'lastname', lastname,
'password', password,
'created', created,
'class_codes', (select JSON_ARRAY('id', id, 'code', code, 'created', created, 'fk_teacher', fk_teacher) from class_codes where fk_teacher=teachers.id)) FROM teachers where teachers.id=18;
不确定如何修复它。