Professional Documents
Culture Documents
Chapter 7 - Application - Website
Chapter 7 - Application - Website
Applications
MSc. Nguyen Khanh Loi
nkloi@hcmut.edu.vn
2/2021
MSc Nguyen Khanh Loi
Content
v MySQL
v Web development
2
MSc Nguyen Khanh Loi
IoT System Architecture
3
MSc Nguyen Khanh Loi
NoSQL vs SQL
4
MSc Nguyen Khanh Loi
SQL and NoSQL Databases
5
MSc Nguyen Khanh Loi
MySQL
What is MySQL?
6
MSc Nguyen Khanh Loi
MySQL
7
MSc Nguyen Khanh Loi
MySQL
8
MSc Nguyen Khanh Loi
MySQL SELECT Statement
Here, column1, column2, ... are the field names of the table you
want to select data from. If you want to select all the fields
available in the table, use the following syntax:
9
MSc Nguyen Khanh Loi
MySQL SELECT Statement
10
MSc Nguyen Khanh Loi
MySQL WHERE Clause
WHERE Syntax
11
MSc Nguyen Khanh Loi
MySQL WHERE Clause
The following SQL statement selects all the customers from "Mexico":
12
MSc Nguyen Khanh Loi
MySQL WHERE Clause
13
MSc Nguyen Khanh Loi
MySQL AND, OR and NOT Operators
The WHERE clause can be combined with AND, OR, and NOT operators.
The AND and OR operators are used to filter records based on more than one condition:
§ The AND operator displays a record if all the conditions separated by AND are TRUE.
§ The OR operator displays a record if any of the conditions separated by OR is TRUE.
§ The NOT operator displays a record if the condition(s) is NOT TRUE.
AND Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
OR Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
NOT Syntax
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
14
MSc Nguyen Khanh Loi
MySQL ORDER BY Keyword
ORDER BY Syntax
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
15
MSc Nguyen Khanh Loi
MySQL ORDER BY Keyword
16
MSc Nguyen Khanh Loi
MySQL INSERT INTO Statement
2. If you are adding values for all the columns of the table, you do not need to
specify the column names in the SQL query. However, make sure the order of
the values is in the same order as the columns in the table. Here, the INSERT
INTO syntax would be as follows:
INSERT INTO table_name
VALUES (value1, value2, value3, ...);
17
MSc Nguyen Khanh Loi
MySQL INSERT INTO Statement
The following SQL statement inserts a new record in the "Customers" table:
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');
18
MSc Nguyen Khanh Loi
MySQL UPDATE Statement
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City = 'Frankfurt'
WHERE CustomerID = 1;
19
MSc Nguyen Khanh Loi
MySQL DELETE Statement
20
MSc Nguyen Khanh Loi
MySQL INNER JOIN Keyword
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
21
MSc Nguyen Khanh Loi
MySQL INNER JOIN Keyword
SELECT Orders.*
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
22
MSc Nguyen Khanh Loi
MySQL INNER JOIN Keyword
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
23
MSc Nguyen Khanh Loi
MySQL RIGHT JOIN Keyword
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
24
MSc Nguyen Khanh Loi
MySQL CROSS JOIN Keyword
SELECT column_name(s)
FROM table1
CROSS JOIN table2;
25
MSc Nguyen Khanh Loi
Practice
https://www.w3schools.com/MySQL/trymysql.asp?filename=trysql_select_columns
26
MSc Nguyen Khanh Loi
Tool
27
MSc Nguyen Khanh Loi
Web development
28
MSc Nguyen Khanh Loi
Web development
29
MSc Nguyen Khanh Loi
Web development
30
MSc Nguyen Khanh Loi
Web development
31
MSc Nguyen Khanh Loi
Web development
32
MSc Nguyen Khanh Loi
Laravel - PHP
33
MSc Nguyen Khanh Loi
MVC Model
34
MSc Nguyen Khanh Loi
Laravel - PHP
https://laravel.com/docs/10.x/installation
Creating A Laravel Project
Your local machine has PHP and Composer installed.
composer create-project laravel/laravel example-app
Start Laravel's local development server using Laravel Artisan's serve
command:
cd example-app
php artisan serve
http://localhost:8000
35
MSc Nguyen Khanh Loi
Laravel - PHP
36
MSc Nguyen Khanh Loi
Laravel - Model
37
MSc Nguyen Khanh Loi
Laravel - Model
38
MSc Nguyen Khanh Loi
Laravel - Controller
39
MSc Nguyen Khanh Loi
Laravel - Controller
40
MSc Nguyen Khanh Loi
Laravel - Routing
routes/web.php
41
MSc Nguyen Khanh Loi
Laravel - View
resources/views/cars/show.blade.php
42
MSc Nguyen Khanh Loi
Laravel - View
http://127.0.0.1:8000/cars/1
43
MSc Nguyen Khanh Loi