SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE TABLE SpecialityDoctors( id int not null primary key, name varchar(256), ); CREATE TABLE Doctors( id int not null primary key, fullName varchar(256), specialityId int not null CONSTRAINT FK_Doctors_SpecialityDoctors FOREIGN KEY (specialityId) REFERENCES SpecialityDoctors(id) ); CREATE TABLE Patients( id int not null primary key, fullName varchar(256) ); CREATE TABLE Preferences( id int not null primary key, IdSpeciality int not null, IdPatient int not null, Preference varchar(512) CONSTRAINT FK_Preference_SpecialityDoctors FOREIGN KEY (IdSpeciality) REFERENCES SpecialityDoctors(id) , CONSTRAINT FK_Preference_Patients FOREIGN KEY (IdPatient) REFERENCES Patients(id) ); CREATE TABLE Appointment( id int not null primary key, IdDoctor int not null, IdPatient int not null, apTime datetime not null, CONSTRAINT FK_Appointment_Doctors FOREIGN KEY (IdDoctor) REFERENCES Doctors(id) , CONSTRAINT FK_Appointment_Patients FOREIGN KEY (IdPatient) REFERENCES Patients(id) ); INSERT INTO SpecialityDoctors (id, name) VALUES (1, 'Cardiologist'), (2, 'Dermatologist'), (3, 'Endocrinologist'); -- -- INSERT INTO Doctors -- INSERT INTO Doctors (id, fullName, specialityId) -- VALUES -- (1, 'John Smith', 1), -- (2, 'Anna Johnson', 2), -- (3, 'Michael Davis', 3); -- -- INSERT INTO Patients -- INSERT INTO Patients (id, fullName) -- VALUES -- (1, 'Emily Brown'), -- (2, 'Daniel Wilson'), -- (3, 'Sophia Martinez'); -- -- INSERT INTO Preference -- INSERT INTO Preferences (Id, IdSpeciality, IdPatient, Preference) -- VALUES -- (1, 1, 1, 'Afraid of injections '), -- (2, 2, 2, 'I have soft skin,'), -- (3, 3, 3, 'I will only go to a woman'); -- -- INSERT INTO Appointment -- INSERT INTO Appointment (Id, IdDoctor, IdPatient, "Time") -- VALUES -- (1, 1, 1, '2023-05-17 10:00:00'), -- (2, 2, 2, '2023-05-18 14:30:00'), -- (3, 3, 3, '2023-05-19 09:45:00'); SELECT p.fullName AS PatientName, d.fullName AS DoctorName, s.name AS Specialty, a.apTime AS AppointmentTime, pr.Preference as Preference FROM Appointment a JOIN Doctors d ON d.id = a.IdDoctor JOIN Patients p ON p.id = a.IdPatient JOIN Preferences pr ON pr.IdPatient = p.id AND pr.IdSpeciality = d.specialityId JOIN SpecialityDoctors s ON s.id = pr.IdSpeciality;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear