-
Notifications
You must be signed in to change notification settings - Fork 0
this is my lesson 1 assignment #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| (1) Using the Customer Table, select the CustomerName, ContactName, and Country. Use ORDER BY to order by Country. | ||
| Use LIMIT and OFFSET to get entries 11 through 20. Paste your SQL statement below. | ||
|
|
||
| SELECT CustomerName, ContactName, Country FROM Customers ORDER BY Country LIMIT 10 OFFSET 10; | ||
|
|
||
| (2) Select all columns from the Customer table where the ContactName starts with A. Paste your SQL statement below. | ||
|
|
||
| SELECT * FROM Customers WHERE ContactName LIKE "A%"; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfectly done. |
||
| (3) Select all columns from the OrderDetails table where the ProductID is 51 and the quantity is greater than 10. | ||
| Paste your SQL statement below. | ||
|
|
||
| SELECT * FROM OrderDetails WHERE ProductID = 51 AND quantity > 10; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well done, exactly how I would have done it. |
||
| (4) Insert 3 rows into the Products table. Note that you will have to specify a valid SupplierID and CategoryID, | ||
| corresponding to rows from the Supplier and Category tables. Paste your three SQL statements below. | ||
|
|
||
| INSERT INTO Products (SupplierID, CategoryID) VALUES (1, 3); | ||
| INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 1); | ||
| INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 4); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works. You could also have done something like below: |
||
| (5) Update the two top rows of the Products Table to increase the price by 1.50. (Get SQL to do the addition for you.) Paste your SQL statement below. | ||
|
|
||
| UPDATE Products SET price = price + 1.50 WHERE ProductID IN ( SELECT ProductID from Products LIMIT 2); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works. In this case your where condition could be simplified to WHERE ProductID IN (1, 2). However, the way you did it does show how subqueries can be used. |
||
| (6) Delete all rows of the Products Table where the price is less than 7.00. Paste your SQL statement below. | ||
|
|
||
| DELETE FROM Products WHERE price < 7.00; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well done. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done.