Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

select item.* as 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+
Source by dba.stackexchange.com #
 
PREVIOUS NEXT
Tagged: #select #json #mysql
ADD COMMENT
Topic
Name
8+5 =