-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueries.sql
20 lines (14 loc) · 891 Bytes
/
queries.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Sample create table
CREATE TABLE users (id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL UNIQUE, admin BOOLEAN NOT NULL DEFAULT false, balance FLOAT NOT NULL DEFAULT 0.0);
-- Sample insert with keys
INSERT INTO users (name, email, admin, balance) VALUES ('John', '[email protected]', FALSE, 0.0), ('Jane', '[email protected]', FALSE, 100.0), ('Foo', '[email protected]', FALSE, 10.0), ('Bar', '[email protected]', FALSE, 20.0);
-- Sample select
SELECT id, name, email, balance FROM users WHERE id BETWEEN 1 AND 10 LIMIT 1, 10;
-- Sample select with ORDER BY
SELECT id, name, email, balance FROM users WHERE id BETWEEN 1 AND 10 ORDER BY balance DESC LIMIT 1, 10;
-- Sample select with wildcard
SELECT * FROM users;
-- Sample update
UPDATE users SET balance = 100.0;
-- Sample update with WHERE clause
UPDATE users SET balance = 100.0 WHERE admin = FALSE;