SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE lesson_students ( lesson_id integer, student_id integer, visit boolean DEFAULT false ); CREATE TABLE students ( id integer NOT NULL, name character varying(10) ); SELECT json_agg(d) FROM ( SELECT json_build_object('id', s.id,'name', s.name, 'visit', lesson_students.visit) d FROM lesson_students JOIN students s on lesson_students.student_id = s.id WHERE lesson_students.lesson_id = 8 ) t;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear