From 34ef8bae9a26bb23150a414c6155772e204d2191 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:22:20 -0500 Subject: [PATCH 01/15] mySQL Everything that I learned on November 30th, but in a folder. --- More Operators/EXERCISE_BETWEEN_STATEMENT.sql | 5 +++++ More Operators/EXERCISE_IN_STATEMENT.sql | 7 +++++++ More Operators/EXERCISE_OPERATORS.sql | 5 +++++ More Operators/mySQL_OPERATORS_BETWEEN.sql | 5 +++++ More Operators/mySQL_OPERATORS_IN.sql | 8 ++++++++ More Operators/mySQL_OPERATORS_LIKE.sql | 7 +++++++ Operators/EXERCISE3_OPERATORS.sql | 6 ++++++ Operators/mySQL_OPERATORS_AND.sql | 9 +++++++++ Operators/mySQL_OPERATORS_AND_OR.sql | 10 ++++++++++ Operators/mySQL_OPERATORS_NOT.sql | 10 ++++++++++ Operators/mySQL_OPERATORS_OR.sql | 9 +++++++++ Select/EXERCISE1.sql | 14 ++++++++++++++ Select/mySQL_SELECT.sql | 6 ++++++ Select/mySQL_SELECTCLAUSE.sql | 11 +++++++++++ Where/EXERCISE2_WHERE.sql | 9 +++++++++ Where/mySQL_WHERE.sql | 9 +++++++++ 16 files changed, 130 insertions(+) create mode 100644 More Operators/EXERCISE_BETWEEN_STATEMENT.sql create mode 100644 More Operators/EXERCISE_IN_STATEMENT.sql create mode 100644 More Operators/EXERCISE_OPERATORS.sql create mode 100644 More Operators/mySQL_OPERATORS_BETWEEN.sql create mode 100644 More Operators/mySQL_OPERATORS_IN.sql create mode 100644 More Operators/mySQL_OPERATORS_LIKE.sql create mode 100644 Operators/EXERCISE3_OPERATORS.sql create mode 100644 Operators/mySQL_OPERATORS_AND.sql create mode 100644 Operators/mySQL_OPERATORS_AND_OR.sql create mode 100644 Operators/mySQL_OPERATORS_NOT.sql create mode 100644 Operators/mySQL_OPERATORS_OR.sql create mode 100644 Select/EXERCISE1.sql create mode 100644 Select/mySQL_SELECT.sql create mode 100644 Select/mySQL_SELECTCLAUSE.sql create mode 100644 Where/EXERCISE2_WHERE.sql create mode 100644 Where/mySQL_WHERE.sql diff --git a/More Operators/EXERCISE_BETWEEN_STATEMENT.sql b/More Operators/EXERCISE_BETWEEN_STATEMENT.sql new file mode 100644 index 0000000..3a4f545 --- /dev/null +++ b/More Operators/EXERCISE_BETWEEN_STATEMENT.sql @@ -0,0 +1,5 @@ +SELECT * +FROM customers +WHERE birth_date BETWEEN '1990-01-01' AND '2000-01-01' + + diff --git a/More Operators/EXERCISE_IN_STATEMENT.sql b/More Operators/EXERCISE_IN_STATEMENT.sql new file mode 100644 index 0000000..652e3ea --- /dev/null +++ b/More Operators/EXERCISE_IN_STATEMENT.sql @@ -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) \ No newline at end of file diff --git a/More Operators/EXERCISE_OPERATORS.sql b/More Operators/EXERCISE_OPERATORS.sql new file mode 100644 index 0000000..25ab75b --- /dev/null +++ b/More Operators/EXERCISE_OPERATORS.sql @@ -0,0 +1,5 @@ +SELECT * +FROM customers +WHERE address LIKE '%tr%' OR address LIKE '%Av%' OR phone LIKE '%9' + + diff --git a/More Operators/mySQL_OPERATORS_BETWEEN.sql b/More Operators/mySQL_OPERATORS_BETWEEN.sql new file mode 100644 index 0000000..21a6a94 --- /dev/null +++ b/More Operators/mySQL_OPERATORS_BETWEEN.sql @@ -0,0 +1,5 @@ +SELECT * +FROM customers +-- WHERE points >= 1000 AND points <= 3000 +-- simplier way: +WHERE points BETWEEN 1000 AND 3000 \ No newline at end of file diff --git a/More Operators/mySQL_OPERATORS_IN.sql b/More Operators/mySQL_OPERATORS_IN.sql new file mode 100644 index 0000000..fe5a266 --- /dev/null +++ b/More Operators/mySQL_OPERATORS_IN.sql @@ -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') + diff --git a/More Operators/mySQL_OPERATORS_LIKE.sql b/More Operators/mySQL_OPERATORS_LIKE.sql new file mode 100644 index 0000000..166d569 --- /dev/null +++ b/More Operators/mySQL_OPERATORS_LIKE.sql @@ -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 */ diff --git a/Operators/EXERCISE3_OPERATORS.sql b/Operators/EXERCISE3_OPERATORS.sql new file mode 100644 index 0000000..ab3ecf6 --- /dev/null +++ b/Operators/EXERCISE3_OPERATORS.sql @@ -0,0 +1,6 @@ +USE sql_store; + +SELECT * +FROM order_items +WHERE (order_id = 6 AND unit_price * quantity > 30) + diff --git a/Operators/mySQL_OPERATORS_AND.sql b/Operators/mySQL_OPERATORS_AND.sql new file mode 100644 index 0000000..30a6251 --- /dev/null +++ b/Operators/mySQL_OPERATORS_AND.sql @@ -0,0 +1,9 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE points > 3000 +-- WHERE state <> 'VA' +WHERE birth_date > '1990-01-01' AND points > 1000 + + diff --git a/Operators/mySQL_OPERATORS_AND_OR.sql b/Operators/mySQL_OPERATORS_AND_OR.sql new file mode 100644 index 0000000..5b0d268 --- /dev/null +++ b/Operators/mySQL_OPERATORS_AND_OR.sql @@ -0,0 +1,10 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE points > 3000 +-- WHERE state <> 'VA' +WHERE birth_date > '1990-01-01' OR + (points > 1000 AND state = 'VA') + + diff --git a/Operators/mySQL_OPERATORS_NOT.sql b/Operators/mySQL_OPERATORS_NOT.sql new file mode 100644 index 0000000..cf9a03f --- /dev/null +++ b/Operators/mySQL_OPERATORS_NOT.sql @@ -0,0 +1,10 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE NOT (birth_date > '1990-01-01' OR points > 1000) + +-- YOU CAN ALSO DO THIS: +WHERE (birth_date <= '1990-01-01' AND points <= 1000) + + diff --git a/Operators/mySQL_OPERATORS_OR.sql b/Operators/mySQL_OPERATORS_OR.sql new file mode 100644 index 0000000..6bcaac3 --- /dev/null +++ b/Operators/mySQL_OPERATORS_OR.sql @@ -0,0 +1,9 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE points > 3000 +-- WHERE state <> 'VA' +WHERE birth_date > '1990-01-01' OR points > 1000 + + diff --git a/Select/EXERCISE1.sql b/Select/EXERCISE1.sql new file mode 100644 index 0000000..07b232f --- /dev/null +++ b/Select/EXERCISE1.sql @@ -0,0 +1,14 @@ +/* EXERCISE 1 TUTORIAL +DIRECTIONS: +1. RETURN ALL THE PRODUCTS +2. NAME +3. UNIT PRICE +4. TAKE UNIT PRICE AND MULTIPLY IT BY 1.1 +*/ + +SELECT + name, + unit_price, + (unit_price * 1.1) AS 'new price' +FROM sql_inventory.products; + diff --git a/Select/mySQL_SELECT.sql b/Select/mySQL_SELECT.sql new file mode 100644 index 0000000..1f027b2 --- /dev/null +++ b/Select/mySQL_SELECT.sql @@ -0,0 +1,6 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE customer_id = 1 +-- ORDER BY first_name diff --git a/Select/mySQL_SELECTCLAUSE.sql b/Select/mySQL_SELECTCLAUSE.sql new file mode 100644 index 0000000..d6c472c --- /dev/null +++ b/Select/mySQL_SELECTCLAUSE.sql @@ -0,0 +1,11 @@ +SELECT + last_name, + first_name, + points, + (points + 10) * 100 AS 'discount factor' +FROM customers + +/* SELECT DISTINCT state +FROM customers +*/ + diff --git a/Where/EXERCISE2_WHERE.sql b/Where/EXERCISE2_WHERE.sql new file mode 100644 index 0000000..ac78e20 --- /dev/null +++ b/Where/EXERCISE2_WHERE.sql @@ -0,0 +1,9 @@ +/* EXERCISE 2: GET THE ORDERS PLACED THIS YEAR */ + +SELECT * +FROM sql_store.orders +WHERE order_date >= '2019-01-01' + + + + diff --git a/Where/mySQL_WHERE.sql b/Where/mySQL_WHERE.sql new file mode 100644 index 0000000..72a6f26 --- /dev/null +++ b/Where/mySQL_WHERE.sql @@ -0,0 +1,9 @@ +USE sql_store; + +SELECT * +FROM customers +-- WHERE points > 3000 +-- WHERE state <> 'VA' +WHERE birth_date > '1990-01-01' + + From b77ef867f11d255b962e239984d1d14fc258235c Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:23:37 -0500 Subject: [PATCH 02/15] Delete EXERCISE1_SELECTCLAUSE.sql in the correct folder. --- EXERCISE1_SELECTCLAUSE.sql | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 EXERCISE1_SELECTCLAUSE.sql diff --git a/EXERCISE1_SELECTCLAUSE.sql b/EXERCISE1_SELECTCLAUSE.sql deleted file mode 100644 index 07b232f..0000000 --- a/EXERCISE1_SELECTCLAUSE.sql +++ /dev/null @@ -1,14 +0,0 @@ -/* EXERCISE 1 TUTORIAL -DIRECTIONS: -1. RETURN ALL THE PRODUCTS -2. NAME -3. UNIT PRICE -4. TAKE UNIT PRICE AND MULTIPLY IT BY 1.1 -*/ - -SELECT - name, - unit_price, - (unit_price * 1.1) AS 'new price' -FROM sql_inventory.products; - From e7256fa25a8c4462b106d2c8647b496a1dcdc71a Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:23:46 -0500 Subject: [PATCH 03/15] Delete EXERCISE2_WHERE.sql in the correct folder. --- EXERCISE2_WHERE.sql | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 EXERCISE2_WHERE.sql diff --git a/EXERCISE2_WHERE.sql b/EXERCISE2_WHERE.sql deleted file mode 100644 index ac78e20..0000000 --- a/EXERCISE2_WHERE.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* EXERCISE 2: GET THE ORDERS PLACED THIS YEAR */ - -SELECT * -FROM sql_store.orders -WHERE order_date >= '2019-01-01' - - - - From cdc041d392180e577fd0194925b493578dd94e44 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:23:54 -0500 Subject: [PATCH 04/15] Delete EXERCISE3_OPERATORS.sql in the correct folder. --- EXERCISE3_OPERATORS.sql | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 EXERCISE3_OPERATORS.sql diff --git a/EXERCISE3_OPERATORS.sql b/EXERCISE3_OPERATORS.sql deleted file mode 100644 index ab3ecf6..0000000 --- a/EXERCISE3_OPERATORS.sql +++ /dev/null @@ -1,6 +0,0 @@ -USE sql_store; - -SELECT * -FROM order_items -WHERE (order_id = 6 AND unit_price * quantity > 30) - From 013044315bbe2c378fb1576185b0e49d89ac21f6 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:24:50 -0500 Subject: [PATCH 05/15] Delete mySQL_WHERE.sql in the correct folder. --- mySQL_WHERE.sql | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 mySQL_WHERE.sql diff --git a/mySQL_WHERE.sql b/mySQL_WHERE.sql deleted file mode 100644 index 72a6f26..0000000 --- a/mySQL_WHERE.sql +++ /dev/null @@ -1,9 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE points > 3000 --- WHERE state <> 'VA' -WHERE birth_date > '1990-01-01' - - From 35b619142ea358b71b9f9e7cc939684abd675ac1 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:12 -0500 Subject: [PATCH 06/15] Delete mySQL_SELECTCLAUSE.sql in the correct folder. --- mySQL_SELECTCLAUSE.sql | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 mySQL_SELECTCLAUSE.sql diff --git a/mySQL_SELECTCLAUSE.sql b/mySQL_SELECTCLAUSE.sql deleted file mode 100644 index d6c472c..0000000 --- a/mySQL_SELECTCLAUSE.sql +++ /dev/null @@ -1,11 +0,0 @@ -SELECT - last_name, - first_name, - points, - (points + 10) * 100 AS 'discount factor' -FROM customers - -/* SELECT DISTINCT state -FROM customers -*/ - From 4dbef194d101fc21a28a61fd84eb3d7859b35ae3 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:21 -0500 Subject: [PATCH 07/15] Delete mySQL_OPERATORS_AND.sql in the correct folder. --- mySQL_OPERATORS_AND.sql | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 mySQL_OPERATORS_AND.sql diff --git a/mySQL_OPERATORS_AND.sql b/mySQL_OPERATORS_AND.sql deleted file mode 100644 index 30a6251..0000000 --- a/mySQL_OPERATORS_AND.sql +++ /dev/null @@ -1,9 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE points > 3000 --- WHERE state <> 'VA' -WHERE birth_date > '1990-01-01' AND points > 1000 - - From 3e7dffbe4266617d33d279c9e3f6da05b75b895d Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:29 -0500 Subject: [PATCH 08/15] Delete mySQL_OPERATORS_AND_OR.sql --- mySQL_OPERATORS_AND_OR.sql | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 mySQL_OPERATORS_AND_OR.sql diff --git a/mySQL_OPERATORS_AND_OR.sql b/mySQL_OPERATORS_AND_OR.sql deleted file mode 100644 index 5b0d268..0000000 --- a/mySQL_OPERATORS_AND_OR.sql +++ /dev/null @@ -1,10 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE points > 3000 --- WHERE state <> 'VA' -WHERE birth_date > '1990-01-01' OR - (points > 1000 AND state = 'VA') - - From 3acb5cd3a3fd14c40bf25e89e20633de69b83309 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:36 -0500 Subject: [PATCH 09/15] Delete mySQL_OPERATORS_NOT.sql --- mySQL_OPERATORS_NOT.sql | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 mySQL_OPERATORS_NOT.sql diff --git a/mySQL_OPERATORS_NOT.sql b/mySQL_OPERATORS_NOT.sql deleted file mode 100644 index cf9a03f..0000000 --- a/mySQL_OPERATORS_NOT.sql +++ /dev/null @@ -1,10 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE NOT (birth_date > '1990-01-01' OR points > 1000) - --- YOU CAN ALSO DO THIS: -WHERE (birth_date <= '1990-01-01' AND points <= 1000) - - From 84f3f743f01578d9c71655d8b4dbb14d003bf5b7 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:44 -0500 Subject: [PATCH 10/15] Delete mySQL_SELECT.sql --- mySQL_SELECT.sql | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 mySQL_SELECT.sql diff --git a/mySQL_SELECT.sql b/mySQL_SELECT.sql deleted file mode 100644 index 1f027b2..0000000 --- a/mySQL_SELECT.sql +++ /dev/null @@ -1,6 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE customer_id = 1 --- ORDER BY first_name From 81a74e9a6be45dba165bc890a0ceac0ccc4477b6 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:26:52 -0500 Subject: [PATCH 11/15] Delete mySQL_OPERATORS_OR.sql --- mySQL_OPERATORS_OR.sql | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 mySQL_OPERATORS_OR.sql diff --git a/mySQL_OPERATORS_OR.sql b/mySQL_OPERATORS_OR.sql deleted file mode 100644 index 6bcaac3..0000000 --- a/mySQL_OPERATORS_OR.sql +++ /dev/null @@ -1,9 +0,0 @@ -USE sql_store; - -SELECT * -FROM customers --- WHERE points > 3000 --- WHERE state <> 'VA' -WHERE birth_date > '1990-01-01' OR points > 1000 - - From 4eed1eceea3a7ee218ba39efd615d98377addc5f Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Mon, 30 Nov 2020 16:50:29 -0500 Subject: [PATCH 12/15] Add files via upload Regular Expressions with the 4 exercises that were apart of it. --- .../Regular Expressions/EXERCISE_REGEXP1.sql | 5 +++++ .../Regular Expressions/EXERCISE_REGEXP2.sql | 3 +++ .../Regular Expressions/EXERCISE_REGEXP3.sql | 3 +++ .../Regular Expressions/EXERCISE_REGEXP4.sql | 3 +++ More Operators/Regular Expressions/mySQL_REGEXP.sql | 13 +++++++++++++ 5 files changed, 27 insertions(+) create mode 100644 More Operators/Regular Expressions/EXERCISE_REGEXP1.sql create mode 100644 More Operators/Regular Expressions/EXERCISE_REGEXP2.sql create mode 100644 More Operators/Regular Expressions/EXERCISE_REGEXP3.sql create mode 100644 More Operators/Regular Expressions/EXERCISE_REGEXP4.sql create mode 100644 More Operators/Regular Expressions/mySQL_REGEXP.sql diff --git a/More Operators/Regular Expressions/EXERCISE_REGEXP1.sql b/More Operators/Regular Expressions/EXERCISE_REGEXP1.sql new file mode 100644 index 0000000..57ad934 --- /dev/null +++ b/More Operators/Regular Expressions/EXERCISE_REGEXP1.sql @@ -0,0 +1,5 @@ +/* REGEXP EXERCISE 1 */ + +SELECT * +FROM customers +WHERE first_name REGEXP 'elka|ambur' \ No newline at end of file diff --git a/More Operators/Regular Expressions/EXERCISE_REGEXP2.sql b/More Operators/Regular Expressions/EXERCISE_REGEXP2.sql new file mode 100644 index 0000000..e3ea6b8 --- /dev/null +++ b/More Operators/Regular Expressions/EXERCISE_REGEXP2.sql @@ -0,0 +1,3 @@ +SELECT * +FROM customers +WHERE last_name REGEXP 'ey$|on$' \ No newline at end of file diff --git a/More Operators/Regular Expressions/EXERCISE_REGEXP3.sql b/More Operators/Regular Expressions/EXERCISE_REGEXP3.sql new file mode 100644 index 0000000..7885642 --- /dev/null +++ b/More Operators/Regular Expressions/EXERCISE_REGEXP3.sql @@ -0,0 +1,3 @@ +SELECT * +FROM customers +WHERE last_name REGEXP '^my|se' \ No newline at end of file diff --git a/More Operators/Regular Expressions/EXERCISE_REGEXP4.sql b/More Operators/Regular Expressions/EXERCISE_REGEXP4.sql new file mode 100644 index 0000000..571a6af --- /dev/null +++ b/More Operators/Regular Expressions/EXERCISE_REGEXP4.sql @@ -0,0 +1,3 @@ +SELECT * +FROM customers +WHERE last_name REGEXP 'b[ru]' \ No newline at end of file diff --git a/More Operators/Regular Expressions/mySQL_REGEXP.sql b/More Operators/Regular Expressions/mySQL_REGEXP.sql new file mode 100644 index 0000000..d4e411a --- /dev/null +++ b/More Operators/Regular Expressions/mySQL_REGEXP.sql @@ -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. From a8320a45990989544cbe32c208a829c28f50fb37 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Wed, 2 Dec 2020 12:43:50 -0500 Subject: [PATCH 13/15] Is Null --- Is Null/Exercise_IS NULL.sql | 5 +++++ Is Null/mySQL_IS NULL.sql | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 Is Null/Exercise_IS NULL.sql create mode 100644 Is Null/mySQL_IS NULL.sql diff --git a/Is Null/Exercise_IS NULL.sql b/Is Null/Exercise_IS NULL.sql new file mode 100644 index 0000000..2b7c522 --- /dev/null +++ b/Is Null/Exercise_IS NULL.sql @@ -0,0 +1,5 @@ +/* Exercise: Get the orders that are not shipped */ + +SELECT * +FROM orders +WHERE shipped_date IS NULL \ No newline at end of file diff --git a/Is Null/mySQL_IS NULL.sql b/Is Null/mySQL_IS NULL.sql new file mode 100644 index 0000000..f2d432a --- /dev/null +++ b/Is Null/mySQL_IS NULL.sql @@ -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 */ + + + From 4dc911535a375d4631354b0b20fa85d526da5098 Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Wed, 2 Dec 2020 12:52:44 -0500 Subject: [PATCH 14/15] Add files via upload updated and added files to folder. --- More Operators/EXERCISE_OPERATORS copy.sql | 5 +++++ More Operators/EXERCISE_ORDERBY.sql | 4 ++++ More Operators/Is Null/Exercise_IS NULL.sql | 5 +++++ More Operators/Is Null/mySQL_IS NULL.sql | 8 ++++++++ More Operators/mySQL_ORDERBY.sql | 9 +++++++++ 5 files changed, 31 insertions(+) create mode 100644 More Operators/EXERCISE_OPERATORS copy.sql create mode 100644 More Operators/EXERCISE_ORDERBY.sql create mode 100644 More Operators/Is Null/Exercise_IS NULL.sql create mode 100644 More Operators/Is Null/mySQL_IS NULL.sql create mode 100644 More Operators/mySQL_ORDERBY.sql diff --git a/More Operators/EXERCISE_OPERATORS copy.sql b/More Operators/EXERCISE_OPERATORS copy.sql new file mode 100644 index 0000000..25ab75b --- /dev/null +++ b/More Operators/EXERCISE_OPERATORS copy.sql @@ -0,0 +1,5 @@ +SELECT * +FROM customers +WHERE address LIKE '%tr%' OR address LIKE '%Av%' OR phone LIKE '%9' + + diff --git a/More Operators/EXERCISE_ORDERBY.sql b/More Operators/EXERCISE_ORDERBY.sql new file mode 100644 index 0000000..19e72e8 --- /dev/null +++ b/More Operators/EXERCISE_ORDERBY.sql @@ -0,0 +1,4 @@ +SELECT *, quantity * unit_price AS total_price +FROM order_items +WHERE order_id = 2 +ORDER BY total_price DESC diff --git a/More Operators/Is Null/Exercise_IS NULL.sql b/More Operators/Is Null/Exercise_IS NULL.sql new file mode 100644 index 0000000..2b7c522 --- /dev/null +++ b/More Operators/Is Null/Exercise_IS NULL.sql @@ -0,0 +1,5 @@ +/* Exercise: Get the orders that are not shipped */ + +SELECT * +FROM orders +WHERE shipped_date IS NULL \ No newline at end of file diff --git a/More Operators/Is Null/mySQL_IS NULL.sql b/More Operators/Is Null/mySQL_IS NULL.sql new file mode 100644 index 0000000..f2d432a --- /dev/null +++ b/More Operators/Is Null/mySQL_IS NULL.sql @@ -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 */ + + + diff --git a/More Operators/mySQL_ORDERBY.sql b/More Operators/mySQL_ORDERBY.sql new file mode 100644 index 0000000..3669d3c --- /dev/null +++ b/More Operators/mySQL_ORDERBY.sql @@ -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. */ + From f9e4f4391d3533af836df5a082624811b389f5bd Mon Sep 17 00:00:00 2001 From: Brendan Allen <99brendanallen@gmail.com> Date: Wed, 2 Dec 2020 13:05:14 -0500 Subject: [PATCH 15/15] Finished Up Operators That was the last operators before moving on to Inner Joins, which will be apart of another folder. I'm planning on creating a big "Operators" folder that has everything that I learned involving operators soon. --- More Operators/EXERCISE_LIMIT.sql | 4 ++++ More Operators/mySQL_LIMIT.sql | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 More Operators/EXERCISE_LIMIT.sql create mode 100644 More Operators/mySQL_LIMIT.sql diff --git a/More Operators/EXERCISE_LIMIT.sql b/More Operators/EXERCISE_LIMIT.sql new file mode 100644 index 0000000..3c973c3 --- /dev/null +++ b/More Operators/EXERCISE_LIMIT.sql @@ -0,0 +1,4 @@ +SELECT * +FROM customers +ORDER BY points DESC +LIMIT 3 -- This should always happen last!! diff --git a/More Operators/mySQL_LIMIT.sql b/More Operators/mySQL_LIMIT.sql new file mode 100644 index 0000000..c4eb9f8 --- /dev/null +++ b/More Operators/mySQL_LIMIT.sql @@ -0,0 +1,3 @@ +SELECT * +FROM customers +LIMIT 6, 3 -- start at 6, then get the next 3 (7,8,9)