1/9
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Create a new database
CREATE DATABASE BooksDBase;
Select the new database
USE BooksDBase;
Create a table
CREATE TABLE BooksTable ( id INT PRIMARY KEY AUTO_INCREMENT, title VARCHAR(100), author VARCHAR(100), price INT(8);
Insert data
INSERT INTO BooksTable (title, author, price) VALUES ('Harry Potter and the Sorcerers Stone', 'J.K. Rowling', 10), ('To Kill a Mockingbird', 'Harper Lee', 9), ('The Great Gatsby', 'F. Scott Fitzgerald', 12);
Retrieve all books
SELECT * FROM BooksTable;
Retrieve books with price > 10
SELECT * FROM BooksTable WHERE price > 10;
Update price of "To Kill a Mockingbird" to 11
UPDATE BooksTable SET price = 11 WHERE title = 'To Kill a Mockingbird';
Delete the book "The Great Gatsby"
DELETE FROM BooksTable WHERE title = 'The Great Gatsby';
Retrieve all books in ascending order by title
SELECT * FROM BooksTable ORDER BY title ASC;
Delete the table
DROP TABLE BooksTable;