- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueries.sql
More file actions
Latest commit
20 lines (14 loc) · 891 Bytes
/
Copy pathqueries.sql
File metadata and controls
20 lines (14 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-- Sample create table
CREATETABLEusers (id INTEGERPRIMARY KEY AUTO_INCREMENT, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL UNIQUE, admin BOOLEANNOT NULL DEFAULT false, balance FLOAT NOT NULL DEFAULT 0.0);
-- Sample insert with keys
INSERT INTO users (name, email, admin, balance) VALUES ('John', 'john@mail.com', FALSE, 0.0), ('Jane', 'jane@mail.com', FALSE, 100.0), ('Foo', 'foo@mail.com', FALSE, 10.0), ('Bar', 'bar@mail.com', FALSE, 20.0);
-- Sample select
SELECT id, name, email, balance FROM users WHERE id BETWEEN 1AND10LIMIT1, 10;
-- Sample select with ORDER BY
SELECT id, name, email, balance FROM users WHERE id BETWEEN 1AND10ORDER BY balance DESCLIMIT1, 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.0WHERE admin = FALSE;