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

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

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

Copy Format Clear
create table category(id int, category_name varchar(255)); insert into category values (1,'Цветы'); select * from category; create table objects(id int, category_id int, object_name varchar(255)); insert into objects values (1,1,'Розы'); select * from objects; create table variations(id int, object_id int, variation_name varchar(255)); insert into variations values (1,1,'Розовые розы') ,(1,1,'Желтые розы') ,(1,1,'Красные розы') ; select * from variations; select o.object_name,c.category_name ,(select group_concat(variation_name) from variations v where v.object_id=o.id) variations from objects o left join category c on o.category_id=c.id;

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

Copy Clear
Copy Format Clear
<?php use Carbon\Carbon; $now = Carbon::now()->format('d/m/Y'); printf("Today is %s\nCurrent PHP version: %s \n\n", $now, phpversion()); $query = " //select category_name from category"; select o.object_name,c.category_name ,(select group_concat(variation_name) from variations v where v.object_id=o.id) variations from objects o left join category c on o.category_id=c.id;"; $stmt = $pdo->prepare($query); $stmt->execute(); $rows = $stmt->fetch(PDO::FETCH_ASSOC); printf('Selected: %s ' . PHP_EOL, count($rows));
Copy Clear