SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table yapbozKategori ( id int, name varchar(64), bannerUrl varchar(500), price int ); insert into yapbozKategori values (1, 'Category1', 'bannerurl', 20); create table yapboz ( id int,kategoriID int, iconUrl varchar(64), imageUrl varchar(500), bannerUrl varchar(500) ); insert into yapboz values (1, 1, 'iconurl1', 'imgurl1', 'bannerur1'),(2, 1, 'yapboz2', 'imgurl2','bannerur2'), (3, 1, 'iconurl3', 'imgurl4','bannerurl3'); SELECT cat.id, cat.name, JSON_ARRAYAGG( JSON_ARRAY('iconUrl',pro.iconUrl,'imageUrl',pro.imageUrl, 'bannerUrl',pro.bannerUrl) ) prod FROM yapboz as pro JOIN yapbozKategori as cat on pro.kategoriID = cat.id GROUP BY cat.id, cat.name ORDER BY cat.id;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear