SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE autor ( id SERIAL primary key, firstname VARCHAR(20) not NULL, lastname VARCHAR(20) not NULL ); INSERT INTO autor(firstname, lastname) VALUES ('George', 'Orwell'), ('J.K.', 'Rowling'), ('F. Scott', 'Fitzgerald'); SELECT * FROM autor; CREATE TABLE book ( id SERIAL primary key, title VARCHAR(40) not NULL, YearPublished VARCHAR(10) not NULL, Price float, AuthorID INTEGER ); INSERT INTO book(title, YearPublished, Price, AuthorID) VALUES ('1984', '1949', 9.99 , 1 ), ('Harry Potter and the Sorcerers Stone ', '1997', 14.99 , 2 ), ('The Great Gatsby', '1925', 10.99 , 3 ); SELECT * FROM book; CREATE TABLE orders ( id SERIAL primary key, OrderDate VARCHAR(40) not NULL, TotalPrice INTEGER ); INSERT INTO orders( OrderDate, TotalPrice) VALUES ('2024-08-01', 25.98), ('2024-08-03', 15.99), ('2024-08-05 ', 7.99); SELECT * FROM orders; SELECT lastname, firstname, title FROM autor JOIN book on AuthorID = book.AuthorID;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear