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 Person ( UserID Int primary key, Name text, Status text, Punkte int ); create table Buch ( BuchID int primary key, Autor int, Verlag text, Seiten int, foreign key (Autor) references Person(UserID) ); create table Review ( UserID int, BuchID int , Datum varchar(30), Inhalt text, primary key(UserID, BuchID, Datum), foreign key (UserID) references Person(UserID), foreign key (BuchID) references Buch(BuchID) ); Insert into Person values (1, "Klaus", "offen", 100), (2, "Annette", "offen", 20), (3, "Bob", "zu", 200), (4, "Rüdiger","published", 0), (5, "Heinrich", "offen", 10); Insert into Buch values (20, 1, "klett",230), (25, 1, "springer", 500), (50, 1, "klett", 100), (30, 2, "klett", 250), (33, 3, "cornelson", 100); Insert into Review values (1, 20, "jejfj", "jgoejo"), (1, 30, "gwfjwafo", "fneiaong"), (5, 20, "ngieagnow", "ngiaoeg"), (5, 33, "heigah", "igeog"), (2, 33, "Ngieb", "igbeo"), (3, 33, "gbegiu", "gueg"); SELECT * FROM Person NATURAL JOIN Review HAVING((COUNT(Person.UserID))=2); SELECT SUM(UserID) FROM Person WHERE UserID NOT IN (SELECT(UserID) FROM (Person NATURAL JOIN Buch));

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

Copy Clear