MySQL examples run on MariaDB. The tables and data are a hidden setup that runs before the reader's query, so every run starts from the same data.
SELECT author, COUNT(*) AS books, MIN(year) AS first FROM book GROUP BY author ORDER BY first;
CREATE TABLE book (id INT PRIMARY KEY, title VARCHAR(60), author VARCHAR(40), year INT); INSERT INTO book VALUES (1, 'Na Drini cuprija', 'Ivo Andric', 1945), (2, 'Prokleta avlija', 'Ivo Andric', 1954), (3, 'Dervis i smrt', 'Mesa Selimovic', 1966), (4, 'Seobe', 'Milos Crnjanski', 1929), (5, 'Tvrdjava', 'Mesa Selimovic', 1970);
Student
- Run the query, then change it: for example
SELECT title FROM book WHERE year > 1950; - An
INSERTorDELETEchanges only your temporary database.
Teacher
- In the dialog choose MySQL (MariaDB) and write
CREATE TABLEandINSERTin the field for the hidden setup. - Needs the CodeLab runner with MariaDB.