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 if not exists Projeto( id_projeto Integer not null primary key auto_increment, nome_projeto varchar(30) ); create table if not exists Peça( id_peça Integer not null primary key auto_increment, nome_peça varchar(30), id_projeto Integer not null, constraint foreign key(id_projeto) references Projeto(id_projeto) ); create table if not exists Pessoa( id_pessoa Integer not null primary key auto_increment, nome_pessoa varchar(30), id_projeto Integer not null, constraint foreign key(id_projeto) references Projeto(id_projeto) ); insert into Projeto(nome_projeto) Values("A1"); insert into Projeto(nome_projeto) Values("A2"); insert into Projeto(nome_projeto) Values("A3"); insert into Projeto(nome_projeto) Values("A4"); insert into Peça(nome_peça,id_projeto) values("parafuso",1); insert into Peça(nome_peça,id_projeto) values("prego",1); insert into Peça(nome_peça,id_projeto) values("Joelho",2); insert into Peça(nome_peça,id_projeto) values("tubo pvc",2); insert into Peça(nome_peça,id_projeto) values("Dobradiça",3); insert into Peça(nome_peça,id_projeto) values("Fechadura",3); insert into Peça(nome_peça,id_projeto) values("Registro",4); insert into Peça(nome_peça,id_projeto) values("Sifão",4); insert into Pessoa(nome_pessoa,id_projeto) values("Davi",1); insert into Pessoa(nome_pessoa,id_projeto) values("João",1); insert into Pessoa(nome_pessoa,id_projeto) values("Pedro",1); insert into Pessoa(nome_pessoa,id_projeto) values("Paulo",2); insert into Pessoa(nome_pessoa,id_projeto) values("Marcos",2); insert into Pessoa(nome_pessoa,id_projeto) values("Antônio",2); insert into Pessoa(nome_pessoa,id_projeto) values("José",3); insert into Pessoa(nome_pessoa,id_projeto) values("Jaime",3); insert into Pessoa(nome_pessoa,id_projeto) values("Vitor",4); insert into Pessoa(nome_pessoa,id_projeto) values("Joaquin",4); select * from Pessoa where id_projeto = 1 select nome_projeto from Projetos where id_projeto = 1

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

Copy Clear