Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Is Null/Exercise_IS NULL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Exercise: Get the orders that are not shipped */

SELECT *
FROM orders
WHERE shipped_date IS NULL
8 changes: 8 additions & 0 deletions Is Null/mySQL_IS NULL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
USE sql_store;

SELECT *
FROM customers
WHERE phone IS NULL /* You can also do IS NOT NULL and it will show up with people who have phone numbers */



5 changes: 5 additions & 0 deletions More Operators/EXERCISE_BETWEEN_STATEMENT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT *
FROM customers
WHERE birth_date BETWEEN '1990-01-01' AND '2000-01-01'


7 changes: 7 additions & 0 deletions More Operators/EXERCISE_IN_STATEMENT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* Exercise:
Return products with
quantity in stock equal to 49,38,72 */

SELECT *
FROM products
WHERE quantity_in_stock IN (49,38,72)
4 changes: 4 additions & 0 deletions More Operators/EXERCISE_LIMIT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT *
FROM customers
ORDER BY points DESC
LIMIT 3 -- This should always happen last!!
5 changes: 5 additions & 0 deletions More Operators/EXERCISE_OPERATORS copy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT *
FROM customers
WHERE address LIKE '%tr%' OR address LIKE '%Av%' OR phone LIKE '%9'


5 changes: 5 additions & 0 deletions More Operators/EXERCISE_OPERATORS.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT *
FROM customers
WHERE address LIKE '%tr%' OR address LIKE '%Av%' OR phone LIKE '%9'


4 changes: 4 additions & 0 deletions More Operators/EXERCISE_ORDERBY.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT *, quantity * unit_price AS total_price
FROM order_items
WHERE order_id = 2
ORDER BY total_price DESC
5 changes: 5 additions & 0 deletions More Operators/Is Null/Exercise_IS NULL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Exercise: Get the orders that are not shipped */

SELECT *
FROM orders
WHERE shipped_date IS NULL
8 changes: 8 additions & 0 deletions More Operators/Is Null/mySQL_IS NULL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
USE sql_store;

SELECT *
FROM customers
WHERE phone IS NULL /* You can also do IS NOT NULL and it will show up with people who have phone numbers */



5 changes: 5 additions & 0 deletions More Operators/Regular Expressions/EXERCISE_REGEXP1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* REGEXP EXERCISE 1 */

SELECT *
FROM customers
WHERE first_name REGEXP 'elka|ambur'
3 changes: 3 additions & 0 deletions More Operators/Regular Expressions/EXERCISE_REGEXP2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT *
FROM customers
WHERE last_name REGEXP 'ey$|on$'
3 changes: 3 additions & 0 deletions More Operators/Regular Expressions/EXERCISE_REGEXP3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT *
FROM customers
WHERE last_name REGEXP '^my|se'
3 changes: 3 additions & 0 deletions More Operators/Regular Expressions/EXERCISE_REGEXP4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT *
FROM customers
WHERE last_name REGEXP 'b[ru]'
13 changes: 13 additions & 0 deletions More Operators/Regular Expressions/mySQL_REGEXP.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SELECT *
FROM customers
-- WHERE last_name REGEXP 'field'
-- WHERE last_name REGEXP '^field' <- this must START with field
-- WHERE last_name REGEXP 'field$' <- this must END with field
/* WHERE last_name REGEXP 'field$|mac|rose' /* <- same as a "IN" statement..
you can apply to the same techniques above */
/* WHERE last_name REGEXP '[gim]e' /* This statement takes an expression and returns anything
that is ge, ie, or me in their last name */
/* WHERE last_name REGEXP 'e[fmq]' /* Same thing as line 8, but at the end of e */
WHERE last_name REGEXP '[a-h]e' /* Same thing as line 10, but at gets anything from a through h */
/* mySQL has more of these expressions, but these are the ones that you
will be using 90% of the time.
3 changes: 3 additions & 0 deletions More Operators/mySQL_LIMIT.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT *
FROM customers
LIMIT 6, 3 -- start at 6, then get the next 3 (7,8,9)
5 changes: 5 additions & 0 deletions More Operators/mySQL_OPERATORS_BETWEEN.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT *
FROM customers
-- WHERE points >= 1000 AND points <= 3000
-- simplier way:
WHERE points BETWEEN 1000 AND 3000
8 changes: 8 additions & 0 deletions More Operators/mySQL_OPERATORS_IN.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT *
FROM customers
-- WHERE state = 'VA' OR state = 'GA' OR state = 'FL'
-- SIMPLIER WAY:
WHERE state IN ('VA', 'GA', 'FL')
-- YOU CAN ALSO DO IT WITH NOT STATEMENTS
-- WHERE state NOT IN ('VA', 'GA', 'FL')

7 changes: 7 additions & 0 deletions More Operators/mySQL_OPERATORS_LIKE.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT *
FROM customers
WHERE last_name LIKE 'b%'

/* Note:
Use % to represent any number of characters
Use _ to represent a single character */
9 changes: 9 additions & 0 deletions More Operators/mySQL_ORDERBY.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT /***/ first_name, last_name, 10 AS points
FROM customers
-- ORDER BY first_name /* You can use DESC for decending */
-- ORDER BY state, first_name
-- ORDER by birth_date
ORDER BY 1,2

/* AVOID THIS FOR NOW... TRY AND LOOK BACK IN THE FUTURE. */

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.