Politics
21 | 22 | 23 | 24 | 25 |Gender: 26 | 32 |
33 |Age:
34 |How often do you vote: 35 | 41 |
42 |Political Party: 43 | 51 |
52 |Who will you vote for: 53 | 61 |
62 |63 | 64 | 65 |
├── CODES
├── S01
│ ├── Development Environment Setup - Overview.txt
│ └── Sign up for cloud based IDE - Text lecture.txt
├── S02
│ ├── Alternate method of running queries - script - Text version.txt
│ ├── Code challenge project - Text version.txt
│ ├── Concat and substring - Text lecture.txt
│ ├── Count, like and group by - Text lecture.txt
│ ├── Create a DatabaseSchema - Text lecture.txt
│ ├── Homework challenge - Text version.txt
│ ├── Inserting rows of data - Text lecture.txt
│ ├── Limit, order by and distinct - Text lecture.txt
│ ├── Min and max - Text lecture.txt
│ ├── Select - Text lecture.txt
│ ├── Solution - Text.txt
│ └── Working with tables - Text lecture.txt
├── S03
│ ├── Case statements - Text lecture.txt
│ ├── Comparison operators - Text lecture.txt
│ ├── Data types in MySQL - Text lecture.txt
│ ├── Date, time and math - Text lecture.txt
│ ├── Dates and times - Text lecture.txt
│ ├── Null and blanks - Text lecture.txt
│ ├── Or - Text lecture.txt
│ ├── Text solution to final project on birthday reporting.txt
│ └── Where and not equal - Text lecture.txt
├── S04
│ ├── Delete - Text lecture.txt
│ ├── Update - Text lecture.txt
│ └── Update based on comparison - Text lecture.txt
├── S05
│ ├── . Left outer joins - Text lecture.txt
│ ├── Data prep for joins - Text lecture.txt
│ ├── Final Project Part 1 - Text solution.txt
│ ├── Final Project Part 2 - Text solution.txt
│ ├── Fix a bad join challenge - Text lecture.txt
│ ├── Inner, Left, Outer and Right joins - Text lecture.txt
│ ├── Joins and aliases - Text lecture.txt
│ ├── Left outer joins - Text lecture.txt
│ ├── More about joins - Text lecture.txt
│ ├── More subselects - Text lecture.txt
│ ├── Primary and foreign keys - Text lecture.txt
│ └── Subselects - Text lecture.txt
├── S06
│ ├── Add browser display - Text follow-up.txt
│ ├── Add styling to form - Text follow-up.txt
│ ├── Complete receiver - Text follow-up.txt
│ ├── Config and other php - Text follow-up.txt
│ ├── Create table - Text follow-up.txt
│ ├── HTML and CSS - Text lecture.txt
│ ├── Learn php basics.txt
│ ├── Preview of web app - Text follow-up.txt
│ ├── Project - Solution text.txt
│ ├── Project start - Text lecture.txt
│ ├── Start SQL Functions - Text lecture.txt
│ ├── Thumbs.db
│ └── learning-php.pdf
├── S07
│ ├── CRUD - Intro - Text follow-up.txt
│ ├── Create action - Text lecture.txt
│ ├── Delete action - Text lecture.txt
│ ├── Read - Text lecture.txt
│ └── Update action - Text lecture.txt
├── S08
│ ├── Complete user sign-up - Text lecture.txt
│ ├── Enforce log in - Text lecture.txt
│ ├── Intro to authentication - Text lecture.txt
│ ├── Login users - Text lecture.txt
│ └── Sessions - Text lecture.txt
├── S09
│ └── Challenge section intro - text reference.txt
├── S10
│ └── Deploy to production - Text lecture.txt
├── S11
│ └── Database permissions section doc.txt
└── S12
│ └── Stored Procedures and Scheduled jobs.txt
├── LICENSE
└── README.md
/CODES/S01/Development Environment Setup - Overview.txt:
--------------------------------------------------------------------------------
1 | IMPORTANT: Development Environment Setup - Overview
2 | Section 1, Lecture 4
3 | To speed up setup and not run into installation issues we will use an online Integrated Development Environment instead of downloading software to our local machine.
4 |
5 | We will cloud9 which is an industry leader in online IDE's and comes pre-installed with everything we need to get started. However, they were purchased by AWS and may require a credit card on file to sign-up. While they don't charge anything (we'll use the free-tier), they keep a credit card on file for security reasons. If you want to skip the AWS sign-up procedure, you can request access to cloud9 from me. I have an instructor account with them and can send you a personal invitation link. This is a manual process and will involve you signing up for my newsletter with valid name, email address and Udemy username (so I can verify that you are a registered student in the course). You can request this access here: http://www.mashrurhossain.com/#inquire
--------------------------------------------------------------------------------
/CODES/S01/Sign up for cloud based IDE - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Sign up for cloud based IDE - Text lecture
2 | Section 1, Lecture 6
3 | To create an account at cloud9, go to c9.io and sign-up for AWS account and then choose C9 from developer tools. However, if you want to use the interface used in the course which is the old c9 workspace (and skip AWS) then you can request access from me directly, details here: http://www.mashrurhossain.com/#inquire
4 |
5 | Select php, apache as your workspace type
6 |
7 | To install MySQL, type the following in your workspace directory and hit return -> mysql-ctl install
8 | To start the MySQL server, type the following and hit return -> mysql-ctl start
9 | To open a command line interface with direct access to your mysql database type in the following and hit return -> mysql-ctl cli
10 |
11 | To see the hostname, type in the following and hit return -> select @@hostname;
12 | **** Don't forget the semi-colon at the end! ****
13 |
14 | To show databases -> show databases;
15 |
16 | To exit the mysql cli -> exit
--------------------------------------------------------------------------------
/CODES/S02/Alternate method of running queries - script - Text version.txt:
--------------------------------------------------------------------------------
1 | Alternate method of running queries - script - Text version
2 | Section 2, Lecture 24
3 | To run a sql script, create a file (example: test1.sql) in your working directory and save it. Add all the sql code you want to run in there.
4 |
5 | Start a SQL cli session and use the source keyword to execute it. If you wanted to run test1.sql type in:
6 | source test1.sql
--------------------------------------------------------------------------------
/CODES/S02/Code challenge project - Text version.txt:
--------------------------------------------------------------------------------
1 | Code challenge project - Text version
2 | Section 2, Lecture 33
3 | CREATE TABLE bowlResults (BowlResultID INT NOT NULL AUTO_INCREMENT
4 |
5 | ,FNAME varchar(50) DEFAULT NULL
6 | ,LNAME varchar(50) DEFAULT NULL
7 | ,Game_Num int DEFAULT NULL
8 | ,Game_Score int DEFAULT NULL
9 | ,PRIMARY KEY (BowlResultID));
10 |
11 | INSERT INTO bowlResults (FNAME, LNAME,Game_Num, Game_Score)
12 | VALUES ('Mashrur', 'Hossain',1,121)
13 | ,('Mashrur', 'Hossain',2,87)
14 | ,('Mashrur', 'Hossain',3,115)
15 | ,('Mashrur', 'Hossain',4,124)
16 | ,('Matt', 'Berstein',1,111)
17 | ,('Matt', 'Berstein',2,99)
18 | ,('Matt', 'Berstein',3,135)
19 | ,('Matt', 'Berstein',4,105)
20 | ,('Anastasia', 'Ivanov',1,75)
21 | ,('Anastasia', 'Ivanov',2,99)
22 | ,('Anastasia', 'Ivanov',3,125)
23 | ,('Anastasia', 'Ivanov',4,141)
24 | ,('Mark', 'Futre',1,115)
25 | ,('Mark', 'Futre',2,128)
26 | ,('Mark', 'Futre',3,101)
27 | ,('Mark', 'Futre',4,84);
28 |
29 | SELECT *
30 | FROM bowlResults;
31 |
32 | SELECT CONCAT(FNAME,' ',LNAME) AS Player
33 | ,SUM(Game_Score) AS "Tournament Total"
34 | ,SUM(Game_Score)/COUNT(*) AS "Tournament Ave"
35 | FROM bowlResults
36 | GROUP BY FNAME, LNAME
37 | ORDER BY SUM(Game_Score)/COUNT(*) DESC
38 | LIMIT 3;
39 |
40 | SELECT CONCAT(FNAME,' ',LNAME) AS Player
41 | ,MAX(Game_Score) AS "Best Game"
42 | FROM bowlResults
43 | GROUP BY FNAME, LNAME
44 | ORDER BY MAX(Game_Score) DESC;
45 |
46 | SELECT DISTINCT FNAME AS "First Name"
47 | ,LNAME AS "Last Name"
48 | FROM bowlResults;
--------------------------------------------------------------------------------
/CODES/S02/Concat and substring - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S02/Concat and substring - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S02/Count, like and group by - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Count, like and group by - Text lecture
2 | Section 2, Lecture 29
3 | Count can be used as follows:
4 |
5 | SELECT COUNT(*) AS cnt
6 | FROM movies;
7 |
8 | This will return the number of movies in the table
9 |
10 | Try the following to get the number of movies for each rating and you'll get incorrect results:
11 | SELECT RATING
12 | ,COUNT(*) AS cnt
13 | FROM movies;
14 | *Incorrect Results
15 |
16 | You can use GROUP BY (column name) to get correct results in such cases:
17 | SELECT RATING
18 | ,COUNT(*) AS MOVIES
19 | FROM movies
20 | GROUP BY RATING;
21 |
22 | Like is used all the time for search when an entire description is not known, it's used with a % -> LIKE %
23 | SELECT *
24 | FROM movies
25 | WHERE TITLE like 'Night at the Museum%';
26 |
27 | Name the return columns with spaces using:
28 | SELECT COUNT(*) AS "Night at the Museum Movies"
29 | FROM movies
30 | WHERE TITLE like 'Night at the Museum%';
31 |
32 | You can put % before the word as well so like '%Museum%' and it will return all results that have museum in the title
--------------------------------------------------------------------------------
/CODES/S02/Create a DatabaseSchema - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S02/Create a DatabaseSchema - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S02/Homework challenge - Text version.txt:
--------------------------------------------------------------------------------
1 | Homework challenge - Text version
2 | Section 2, Lecture 20
3 | Phase 1:
4 |
5 | Create a table which should have the following columns:
6 | Primary Key (int), Fname, Lname, Game1, Game2, Game3, Game4
7 |
8 | Fill in data for the table with your and 3 of your friends names and 4 game scores (remember id for each row, primary key, should be assigned automatically)
9 |
10 | Phase 2:
11 | Create a report from the data in the table:
12 | Exclude ID column
13 | - Each column should have a custom header/title, atleast 1 should have a space in it
14 | - A column with player initials
15 | - A column with last name, first name separated by comma
16 | - Return each game's score
17 | - Column with total score of all four games for each player
18 | - Column with average score for each player
19 |
20 | IMPORTANT: Please post your code to the Q & A section for this lecture (or the prior video lecture)
--------------------------------------------------------------------------------
/CODES/S02/Inserting rows of data - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S02/Inserting rows of data - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S02/Limit, order by and distinct - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S02/Limit, order by and distinct - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S02/Min and max - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S02/Min and max - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S02/Select - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Select - Text lecture
2 | Section 2, Lecture 16
3 | SELECT * FROM actors;
4 |
5 | SELECT * FROM movies;
6 |
7 | -> SELECT section lists the results to be returned.
8 | * Means everything
9 | From is where you list tables.
10 | We will add lots of extra details but the SELECT * FROM is the general structure of how we retrieve any and all data from the database.
11 |
12 | Listing the columns returns the same results as *
13 | SELECT ActorID
14 | ,FIRST_NAME
15 | ,LAST_NAME
16 | FROM actors;
17 |
18 | SELECT FIRST_NAME
19 | ,LAST_NAME
20 | FROM actors;
21 | Returns same number of rows, but only the columns that were requested (FIRST_NAME AND LAST_NAME)
--------------------------------------------------------------------------------
/CODES/S02/Solution - Text.txt:
--------------------------------------------------------------------------------
1 | Solution - Text
2 | Section 2, Lecture 22
3 | CREATE TABLE players1 (BowlerID INT NOT NULL AUTO_INCREMENT
4 |
5 | ,FNAME varchar(50) DEFAULT NULL
6 | ,LNAME varchar(50) DEFAULT NULL
7 | ,Game1 int DEFAULT NULL
8 | ,Game2 int DEFAULT NULL
9 | ,Game3 int DEFAULT NULL
10 | ,Game4 int DEFAULT NULL
11 | ,PRIMARY KEY (BowlerID));
12 | INSERT INTO players1 (FNAME, LNAME,Game1,Game2,Game3,Game4)
13 | VALUES ('Mashrur', 'Hossain',121,87,115,124)
14 | ,('Matt', 'Berstein',111,99,135,105)
15 | ,('Anastasia', 'Ivanov',75,99,125,141)
16 | ,('Mark', 'Futre',115,128,101,84);
17 |
18 | SELECT *
19 | FROM players1;
20 |
21 | SELECT CONCAT(LNAME,', ',FNAME) AS Player
22 | ,CONCAT(SUBSTRING(FNAME,1,1),SUBSTRING(LNAME,1,1)) AS Initials
23 | ,GAME1 AS G1
24 | ,GAME2 AS G2
25 | ,GAME3 AS G3
26 | ,GAME4 AS G4
27 | ,GAME1 + GAME2 + GAME3 + GAME4 AS "Tournament Total"
28 | ,(GAME1 + GAME2 + GAME3 + GAME4)/4 AS "Tournament Average"
29 | FROM players1;
--------------------------------------------------------------------------------
/CODES/S02/Working with tables - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Working with tables - Text lecture
2 | Section 2, Lecture 12
3 | - Tables are just like Excel Spreadsheets
4 |
5 | - Columns have headers and are for certain types of data like strings, dates, numbers etc.
6 | - Rows are the actual data which all fit inside the column data types.
7 |
8 | - Structure matters. Forgetting a comma or a line or a space can break things.
9 |
10 | To create a table called people (The capitalization of CREATE TABLE below is to separate out the sql code from the names of the tables, you can also just say create table, capitalization matters in column names):
11 | CREATE TABLE people ( PersonID int
12 | ,first_name varchar(100)
13 | ,last_name varchar(100)
14 | );
15 |
16 | To show database in use, type in select database();
17 | show tables;
18 |
19 | CREATE TABLE people2 ( PersonID INT NOT NULL AUTO_INCREMENT
20 | ,FIRST_NAME VARCHAR(100) NULL
21 | ,LAST_NAME VARCHAR(100) NULL
22 | ,PRIMARY KEY (PersonID));
23 |
24 | Primary Key is a unique value that each row will have, auto_increment makes it easy by automatically assigning them
25 |
26 | If we want to remove a table, use DROP TABLE (or drop table)
27 | show tables;
28 |
29 | To add a column, first see the columns that are there by typing in -> show columns from people2;
30 |
31 | Notice there are 3 columns;
32 |
33 | To add a column called DOB:
34 | alter table people2 add column DOB date NULL;
35 |
36 | Similarly, to drop a column, type in:
37 | alter table people2 drop column DOB;
38 | show columns from people2;
39 |
40 | To delete tables:
41 | drop table people;
42 | drop table people2;
43 |
44 | This will get rid of both tables
45 |
46 | Homework exercise: Create two tables - actors and movies
47 | actors will have columns ActorID (as primary key), first_name, last_name and specify primary key
48 | movies will have columns MovieID (as primary key), title, release_year, rating and specify primary key
--------------------------------------------------------------------------------
/CODES/S03/Case statements - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Case statements - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Comparison operators - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Comparison operators - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Data types in MySQL - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Data types in MySQL - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Date, time and math - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Date, time and math - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Dates and times - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Dates and times - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Null and blanks - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Null and blanks - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S03/Or - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Or - Text lecture
2 | Section 3, Lecture 41
3 | OR Will allow you to have distinct conditions that may otherwise conflict
4 |
5 | example:
6 | SELECT *
7 | FROM movies
8 | WHERE RATING = "R"
9 | OR Title LIKE "Zoo%";
10 |
11 | Both of these accomplish the same thing but ()s and spacing help avoid mistakes.
12 |
13 | SELECT *
14 | FROM movies
15 | WHERE ( RATING = "R"
16 | OR Title LIKE "Zoo%");
--------------------------------------------------------------------------------
/CODES/S03/Text solution to final project on birthday reporting.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Text solution to final project on birthday reporting.txt
--------------------------------------------------------------------------------
/CODES/S03/Where and not equal - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S03/Where and not equal - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S04/Delete - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Delete - Text lecture
2 | Section 4, Lecture 57
3 | Delete is just like Select but instead of returning rows with information, it removes them from the table. As a rule, always use a select statement to verify what you are about to remove.
4 |
5 | Example, remove all of the inactive accounts from our CustBal table:
6 |
7 | First, identify the inactive accounts:
8 | SELECT *
9 | FROM CustBal
10 | WHERE ActiveStatus = 0;
11 |
12 | To delete, replace SELECT * with DELETE and execute;
13 | DELETE
14 | FROM CustBal
15 | WHERE ActiveStatus = 0;
--------------------------------------------------------------------------------
/CODES/S04/Update - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Update - Text lecture
2 | Section 4, Lecture 53
3 | In previous lectures we learned about select like below:
4 |
5 | SELECT title
6 | ,release_year
7 | FROM movies
8 | WHERE release_year IS NULL;
9 |
10 | If we want to update or change the data, we use UPDATE instead of select:
11 | Use a select to find what to update
12 | SELECT *
13 | FROM movies
14 | WHERE Title = 'Fight Club';
15 |
16 | Then run an update on the same selection criteria:
17 | UPDATE movies
18 | SET ReleaseYear = 1999
19 | WHERE Title = 'Fight Club';
20 |
21 | We can update multiple rows and multiple columns at the same time:
22 | SELECT *
23 | FROM movies
24 | WHERE title IN ('DodgeBall: A True Underdog Story'
25 | ,'Along Came Polly'
26 | ,'Anchorman:The Legend of Ron Burgundy');
27 |
28 | Rows matched:3 Changed:3
29 | If you run this again, it will say matched: 3, Changed: 0
30 |
31 | Use SELECT * to verify your WHERE before updating a table.
--------------------------------------------------------------------------------
/CODES/S04/Update based on comparison - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S04/Update based on comparison - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/. Left outer joins - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/. Left outer joins - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Data prep for joins - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/Data prep for joins - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Final Project Part 1 - Text solution.txt:
--------------------------------------------------------------------------------
1 | Final Project Part 1 - Text solution
2 | Section 5, Lecture 77
3 | Challenge: Update with Joins
4 |
5 | Objective: Alter the bowlers table to not keep the individual game scores. Instead we will have a Running Average score (int) based on the results from bowlresults, ensure the names of the bowlers match in both tables (FNAME and LNAME)
6 |
7 | You will need need some new functions for this:
8 | AVE() to pull the average of a grouped value
9 | ROUND() will round to an integer * use google to find and see examples of these functions
10 |
11 | Step 1, drop the unneeded columns from bowlers table:
12 | ALTER TABLE bowlers
13 | DROP COLUMN Game1
14 | ,DROP COLUMN Game2
15 | ,DROP COLUMN Game3
16 | ,DROP COLUMN Game4;
17 |
18 | Step 2: Add new column to bowlers:
19 | ALTER TABLE bowlers
20 | ADD COLUMN AveScore int DEFAULT NULL;
21 |
22 | Step 3: Plan the Update
23 | SELECT A.FNAME
24 | ,A.LNAME
25 | ,AVG(B.Game_Score) AS RawAveScore
26 | ,ROUND(AVG(B.Game_Score)) AS AveScore
27 | FROM bowlers A
28 | ,bowlResults B
29 | WHERE A.FNAME = B.FNAME
30 | AND A.LNAME = B.LNAME
31 | GROUP BY A.FNAME
32 | ,A.LNAME;
33 |
34 | Step 4: Create the update statement from the select
35 |
36 | UPDATE bowlers A
37 | SET AveScore = (SELECT ROUND(AVG(Game_Score)) AS AveScore
38 | FROM bowlResults B
39 | WHERE B.FNAME = A.FNAME
40 | AND B.LNAME = A.LNAME);
41 | SELECT * FROM bowlers;
42 |
43 | CONGRATULATIONS!
--------------------------------------------------------------------------------
/CODES/S05/Final Project Part 2 - Text solution.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/Final Project Part 2 - Text solution.txt
--------------------------------------------------------------------------------
/CODES/S05/Fix a bad join challenge - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/Fix a bad join challenge - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Inner, Left, Outer and Right joins - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Inner, Left, Outer and Right joins - Text lecture
2 | Section 5, Lecture 67
3 | Before we go any further with Joins, let's get the main types straight: INNER, LEFT OUTER, RIGHT OUTER and FULL OUTER.
4 |
5 | There are a few ways to specify these types in SQL, but for the purposes of this course, we will stick to these terms: LEFT OUTER JOIN is often called a LEFT JOIN, and an INNER JOIN may be referred to as a JOIN. A FULL OUTER JOIN can be called an OUTER JOIN. etc.
6 |
7 | Imagine we have two tables:
8 |
9 | Table A
10 | ColA
11 | 1
12 | 2
13 | 3
14 | 4
15 |
16 | Table B
17 | ColB
18 | 3
19 | 4
20 | 5
21 | 6
22 |
23 | If we were to join these tables together, the number of rows returned would depend on the join we use. Notice 1 and 2 are unique to Table A, 5 and 6 are unique to table B. 3 and 4 are common to both tables.
24 |
25 | SELECT *
26 | FROM A INNER JOIN B ON A.ColA = B.ColB;
27 |
28 | This would return:
29 | ColA | ColB
30 | 3 | 3
31 | 4 | 4
32 | INNER JOIN requires that the value be on both tables
33 |
34 | SELECT *
35 | FROM A LEFT OUTER JOIN B ON A.ColA = B.ColB;
36 |
37 | This would return:
38 | ColA | ColB
39 | 1 | NULL
40 | 2 | NULL
41 | 3 | 3
42 | 4 | 4
43 | LEFT OUTER JOIN returns everything from the first table (left) whether or not the second table has a corresponding row
44 |
45 | SELECT *
46 | FROM A RIGHT OUTER JOIN B ON A.ColA = B.ColB;
47 |
48 | This would return:
49 | ColA | ColB
50 | 3 | 3
51 | 4 | 4
52 | NULL| 5
53 | NULL| 6
54 | RIGHT OUTER JOIN returns everything from the second table (right) whether or not the first table has a corresponding row
55 |
56 | SELECT *
57 | FROM A FULL OUTER JOIN B ON A.ColA = B.ColB;
58 |
59 | This would return:
60 | ColA | ColB
61 | 1 | NULL
62 | 2 | NULL
63 | 3 | 3
64 | 4 | 4
65 | NULL| 5
66 | NULL| 6
67 | FULL OUTER JOIN returns everything from both tables whether or not there are corresponding rows
--------------------------------------------------------------------------------
/CODES/S05/Joins and aliases - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/Joins and aliases - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Left outer joins - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Left outer joins - Text lecture
2 | Section 5, Lecture 69
3 | Let's say we want to report all of the actors and the movies that they directed:
4 |
5 | SELECT A.FIRST_NAME
6 | ,A.LAST_NAME
7 | ,B.TITLE AS Directed
8 | ,B.RELEASE_YEAR
9 | FROM people A
10 | INNER JOIN movies B
11 | ON B.DIRECTOR = A.ActorID;
12 |
13 | If I want to have rows from the people table returned whether or not they directed a movie, I can use a left outer join:
14 |
15 | SELECT A.FIRST_NAME
16 | ,A.LAST_NAME
17 | ,B.TITLE AS Directed
18 | ,B.RELEASE_YEAR
19 | FROM people A
20 | LEFT OUTER JOIN movies B
21 | ON B.DIRECTOR = A.ActorID;
22 |
23 | We can couple this concept with functions we discussed earlier like Min and Max
24 |
25 | SELECT A.FIRST_NAME
26 | ,A.LAST_NAME
27 | ,MIN(C.RELEASE_YEAR) AS FirstDirected
28 | ,MAX(B.RELEASE_YEAR) AS LatestRelease
29 | FROM people A
30 | LEFT OUTER JOIN movies B
31 | ON B.DIRECTOR = A.ActorID
32 | LEFT OUTER JOIN movies C
33 | ON C.DIRECTOR = A.ActorID
34 | GROUP BY A.FIRST_NAME ,A.LAST_NAME
35 | ORDER BY COUNT(B.MovieID) DESC;
36 |
37 | When your joining tables, you can join them to the primary table or any table, but it is important to keep them in a logical order so that you can troubleshoot if you run into unexpected results.
38 |
39 | SELECT A.FIRST_NAME
40 | ,A.LAST_NAME
41 | ,IFNULL(MIN(C.ReleaseYear),'N/A') AS FirstDirected
42 | ,IFNULL(MAX(B.ReleaseYear),'N/A') AS LatestRelease
43 | FROM people A
44 | LEFT OUTER JOIN movies B
45 | ON B.director = A.ActorID
46 | LEFT OUTER JOIN movies C
47 | ON C.director = B.director
48 | GROUP BY A.FIRST_NAME
49 | ,A.LAST_NAME;
--------------------------------------------------------------------------------
/CODES/S05/More about joins - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/More about joins - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/More subselects - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/More subselects - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Primary and foreign keys - Text lecture.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S05/Primary and foreign keys - Text lecture.txt
--------------------------------------------------------------------------------
/CODES/S05/Subselects - Text lecture.txt:
--------------------------------------------------------------------------------
1 | Subselects - Text lecture
2 | Section 5, Lecture 73
3 | SQL allows queries inside of other quiries which can be extermely useful. Take our example from the previous lecture. If we want to know how many movies each director directed, a subselect can easily do the job.
4 |
5 | SELECT A.FIRST_NAME
6 | ,A.LAST_NAME
7 | ,IFNULL(MIN(C.Release_Year),'N/A') AS FirstDirected
8 | ,IFNULL(MAX(B.Release_Year),'N/A') AS LatestRelease
9 | ,D.cnt AS MoviesDirected
10 | FROM people A
11 | LEFT OUTER JOIN movies B
12 | ON B.director = A.ActorID
13 | LEFT OUTER JOIN movies C
14 | ON C.director = B.director
15 | LEFT OUTER JOIN (SELECT Z.Director AS ActorID
16 | ,COUNT(Z.MovieID) AS cnt
17 | FROM movies Z
18 | GROUP BY Z.Director) D
19 | ON D.ActorID = A.ActorID
20 | GROUP BY A.FIRST_NAME
21 | ,A.LAST_NAME
22 | ,D.cnt
23 | ORDER BY D.cnt DESC;
24 |
25 | While there are performance hits from subselects in the SELECT section, it also is an option:
26 | SELECT A.FIRST_NAME
27 | ,A.LAST_NAME
28 | ,IFNULL(MIN(C.Release_Year),'N/A') AS FirstDirected
29 | ,IFNULL(MAX(B.Release_Year),'N/A') AS LatestRelease
30 | ,(SELECT COUNT(Z.MovieID)
31 | FROM movies Z
32 | WHERE Z.Director = A.ActorID) AS MoviesDirected
33 | FROM people A
34 | LEFT OUTER JOIN movies B
35 | ON B.director = A.ActorID
36 | LEFT OUTER JOIN movies C
37 | ON C.director = B.director
38 | GROUP BY A.FIRST_NAME
39 | ,A.LAST_NAME
40 | ORDER BY MoviesDirected DESC;
--------------------------------------------------------------------------------
/CODES/S06/Add browser display - Text follow-up.txt:
--------------------------------------------------------------------------------
1 | Add browser display - Text follow-up
2 | Section 6, Lecture 99
3 | Create a new file titled OptInDisplay.php
4 |
5 | Source Table: ' . $table;
14 |
15 | /*check to see if the table exists*/
16 | if (!f_tableExists($link, $table, DB_NAME) ) {
17 | die('
Destination Table Does Not Exist:'.$table);
18 | }
19 |
20 | /*Query contents of source table*/
21 | $sql="SELECT * FROM $table ";
22 | echo '
sql :'.$sql;
23 | if ($result = mysqli_query($link,$sql)){
24 | echo "
OptInID | "; 28 | echo "formID | "; 29 | echo "First Name | "; 30 | echo "Last Name | "; 31 | echo "Email Addess | "; 32 | echo "Date/Time | "; 33 | echo "Source IP | "; 34 | echo "SuccessUrl | "; 35 | echo "RejectUrl | "; 36 | echo "tags 39 | while ($row = mysqli_fetch_array($result)) { 40 | echo " |
{$row[0]} | "; 42 | echo "{$row[1]} | "; 43 | echo "{$row[2]} | "; 44 | echo "{$row[3]} | "; 45 | echo "{$row[4]} | "; 46 | echo "{$row[5]} | "; 47 | echo "{$row[6]} | "; 48 | echo "{$row[7]} | "; 49 | echo "{$row[8]} | "; 50 | echo "
Gender: 26 | 32 |
33 |Age:
34 |How often do you vote: 35 | 41 |
42 |Political Party: 43 | 51 |
52 |Who will you vote for: 53 | 61 |
62 |PoliticalPollID | "; 109 | echo "formID | "; 110 | echo "Gender | "; 111 | echo "Age | "; 112 | echo "Voting Frequency | "; 113 | echo "Party | "; 114 | echo "Cadidate | "; 115 | echo "EntryTimeStamp | "; 116 | echo "Source IP | "; 117 | echo "SuccessUrl | "; 118 | echo "RejectUrl | "; 119 | echo "
{$row[0]} | "; 125 | echo "{$row[1]} | "; 126 | echo "{$row[2]} | "; 127 | echo "{$row[3]} | "; 128 | echo "{$row[4]} | "; 129 | echo "{$row[5]} | "; 130 | echo "{$row[6]} | "; 131 | echo "{$row[7]} | "; 132 | echo "{$row[8]} | "; 133 | echo "{$row[9]} | "; 134 | echo "{$row[10]} | "; 135 | echo "
To-do Title:
19 |To-Due Date:
20 |Description:
Title"; 145 | echo " | Description"; 146 | echo " | DueDate"; 147 | echo " | Action"; 148 | echo " |
---|---|---|---|
{$row[0]} | "; 156 | echo "{$row[1]} | "; 157 | echo "{$row[2]} | "; 158 | echo ""; 159 | echo " |
79 | 80 | 81 | 82 | Try the form out. 83 | There are all sorts of good security practices that we could implement, but for now, this will accomplish basic functionality. -------------------------------------------------------------------------------- /CODES/S08/Enforce log in - Text lecture.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S08/Enforce log in - Text lecture.txt -------------------------------------------------------------------------------- /CODES/S08/Intro to authentication - Text lecture.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/The-Complete-MySQL-Developer-Course/3ca7ee91dea2c5c34cf5586f2b8f982ef188991b/CODES/S08/Intro to authentication - Text lecture.txt -------------------------------------------------------------------------------- /CODES/S08/Login users - Text lecture.txt: -------------------------------------------------------------------------------- 1 | Login users - Text lecture 2 | Section 8, Lecture 117 3 | Now lets create a Login page Login.php 4 | 5 | 6 |
7 |116 | 117 | 118 | 119 | Test this by attempting to log in intentionally fail the validations. 120 | Once tested, uncomment the header location row that forwards users to ToDoApp.php once they are logged in. Then you should be able to test logging in with correct credentials 121 | 122 | Now lets create a logout page Logout.php 123 | 132 | 133 |
134 |