Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE modx_ms2_orders ( id int primary key auto_increment, num int, createdon datetime, cost int, status int, user_id int ); CREATE TABLE modx_ms2_order_products ( id int primary key auto_increment, order_id int, name varchar(255), count int, cost int ); SELECT orders.num, orders.createdon, orders.cost, orders.status, JSON_ARRAYAGG(JSON_OBJECT('name', products.name, 'count', products.count, 'cost', products.cost)) products FROM `modx_ms2_orders` AS orders JOIN `modx_ms2_order_products` AS products ON orders.id = products.order_id WHERE `user_id` = 106 GROUP BY orders.num, orders.createdon, orders.cost, orders.status

Stuck with a problem? Got Error? Ask AI support!

Copy Clear