SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table block ( id int generated always as identity primary key, "name" text, "position" smallint ); create table block_variants ( id int generated always as identity primary key, block_id int references block (id), "text" text ); insert into block ("name", "position") values ('приветствие', 1), ('основной текст', 2), ('завершение', 3); insert into block_variants (block_id, "text") values (1, 'Привет тебе'), (1, 'Здрасьте'), (2, 'Увеличьте пенис'), (2, 'Вы выиграли миллиард'), (3, 'Пока'), (3, 'До свидания'); select distinct on (block_id) id, block_id, "text" from block_variants order by block_id, random();
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear