Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. How many users are there? 50
- SELECT COUNT(*) FROM users;
- 2. What are the 5 most expensive items?
- 25|Small Cotton Gloves|Automotive, Shoes & Beauty|Multi-layered modular service-desk|9984
- 83|Small Wooden Computer|Health|Re-engineered fault-tolerant adapter|9859
- 100|Awesome Granite Pants|Toys & Books|Upgradable 24/7 access|9790
- 40|Sleek Wooden Hat|Music & Baby|Quality-focused heuristic info-mediaries|9390
- 60|Ergonomic Steel Car|Books & Outdoors|Enterprise-wide secondary firmware|9341
- SELECT * FROM items ORDER BY price DESC LIMIT 5;
- 3. What's the cheapest book? 76|Ergonomic Granite Chair|Books|De-engineered bi-directional portal|1496
- SELECT * FROM items WHERE category = 'Books' ORDER BY price LIMIT 1;
- return does not change by using
- SELECT * FROM items WHERE category LIKE '%Books%' ORDER BY price LIMIT 1;
- 4. Who lives at "6439 Zetta Hills, Willmouth, WY"? Do they have another address? user_id 40, Corrine Little
- SELECT * FROM addresses WHERE street ='6439 Zetta Hills';
- and yes, their second address is 54369 Wolff Forges|Lake Bryon|CA|31587
- SELECT * FROM users WHERE id ="40"
- 40|Corrine|Little|rubie_kovacek@grimes.net
- 5. Correct Virginie Mitchell's address to " New York, NY 12345".
- SELECT * FROM addresses WHERE user_id = "39";
- UPDATE addresses SET zip="12345" WHERE id = "41";
- 6. How many total items did we sell? 2125
- SELECT SUM(quantity) FROM orders;
- 7. Simulate buying an item by inserting a User for yourself and an Order for that User.
- INSERT INTO users (id, first_name, last_name, email) VALUES ("51", "Huy", "Luong", "huy@tiy.com");
- INSERT INTO orders (id, user_id, item_id,quantity, created_at) VALUES ("378", "51", "69","100", "2017-01-18 16:00:27:123677");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement