Wybierz element.* Jako JSON MYSQL

-- You can't use * in json selects in all version of mySQL, but you can 
-- outline all fields you want in a select statement as follows: 
SELECT contact.*, JSON_OBJECT(
  'name_field', name_field,
  'address_field', address_field,
  'contact_age', contact_age
) AS location
FROM contact
JOIN location on contact.loc_id = location.id;

-- You may be able to use "JSON_ARRAYAGG()" for this in mySQL 8+
PDXfoster