0% found this document useful (0 votes)
24 views68 pages

MySQL Database Development Course Guide

Uploaded by

islayfemboys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views68 pages

MySQL Database Development Course Guide

Uploaded by

islayfemboys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Faculty Of Business, Economics &

Information Systems

INF303E
Data Base
DR. Amr Muhammad Abd-Elwahed
The course offers hands-on experience in developing client/server database applications
using a major database management system. Students learn how to create and
manipulate database objects, including tables, views, and sequences; develop program
units using SQL; and implement client applications such as forms and reports. The course
provides students with first- hand experience developing prototyping client/server
applications. Topics include the investigation and applications of advanced concepts such
as integrity, security, concurrency and recovery, object-oriented database design, current
developments and trends in DBMS. The course introduces the student to the process of
database development, including data modeling, database design, and database
implementation. Students learn basic interactive SQL for both data definition and
queries. Students practice design skills by developing a small database project.
Course Outlines

❑ MySQL Database
• CREATE - INSERT INTO
• SELECT FROM
• UPDATE – DELETE
• ALTER
• If statement- Case statement
• NULL functions - Comment - View
• IMPORT/EXPORT data
• Tables Relationships
• CREATE TABLE from other table/tables in the same/different database
• INSERT/UPDATE DATA from other table/tables in the same/different database
❑ PHP => MySQL database
❑ Python => MySQL database
❑ Python <=> PHP
❑ Database Security (PHP & Python)
• Regular Regression • SSL Certification
• Password • SQL injection attack
• Hash function • XSS attack
• Public-Key cryptography • POST/GET methods
• Symmetrical cryptography • MySQL Default Account (root)
• Digital Signature • Hints on other Security Topics
Chapter 1: MySQL Database

Overall Objectives of Chapter


• Introduction on Database
• CREATE - INSERT INTO
• SELECT FROM
• UPDATE – DELETE
• ALTER
• If statement- Case statement
• NULL functions - Comment - View
• IMPORT/EXPORT data
• Tables Relationships
• CREATE TABLE from other table/tables in the same/different database
• INSERT/UPDATE DATA from other table/tables in the same/different database 5
Intended Learning Outcomes
After Finishing this chapter Student will be able to

Recognize the benefit of each step of MySQL database.

Describe SELECT statement to do the correct query on the database.

Identify the syntax of create/edit/query on the tables in the databases

Explain The effect of the different clauses and functions on the table(s)

Explain The tables relationships to create a report/table.

6
Introduction
& XAMPP Installing
Introduction
Database
A database is an organized collection of structured information, or data, typically stored
electronically in a computer system. A database is usually controlled by a Database
Management System (DBMS).
Database Management System (DBMS)
DBMS is software that serves as an interface between an end-user and a database, allowing
users to create, read, update, delete, manage, and manipulate data in the database.
Relational Database (RDB)
RDB is a way of structuring information in tables, rows, and columns. An RDB has the ability to
establish links—or relationships–between information by joining tables, which makes it easy
to understand and gain insights about the relationship between various data points.

Relational Database Management System (RDBMS)


RDBMS is a program used to create, update, and manage relational databases.
SQL Database vs. NoSQL Database
Structured Query Language (SQL) database is a relational database whereas NoSQL
database is a non-relational database. So, SQL database is managed by Relational Database
Management System (RDBMS) while NoSQL database is not. But NoSQL database managed
by Database Management System (DBMS).
More details about the difference between them:
[Link]
Some examples of SQL databases include:
▪ Microsoft Access ▪ MySQL ▪ PostgreSQL ▪ Microsoft SQL Server.
▪ SQLite ▪ Oracle ▪ IBM DB2 ▪ Backendless

NoSQL database examples include:


▪ MongoDB ▪ BigTable ▪ Redis ▪ Cassandra
▪ Hbase ▪ Neo4j ▪ CouchDB
MySQL Database
In our course, we will be interested in MySQL database. It is one of the popular databases
used. We can access on MySQL by different ways such as:
▪ Command Prompt
▪ phpMyAdmin
▪ PHP language
▪ Programs: Python, Java , etc.

There is two popular ways used to install MySQL:


• MySQL installer
[Link]
• XAMPP:
To learn how to access MySQL from Command prompt and phpMyAdmin, from this link:
[Link]

You can see more details on MySQL in this link:


[Link]
MySQL can create the databases and tables by using one of the next two methods:
▪ Command Line Interface(CLI)
▪ Graphical User Interface(GUI)

Example on MySQL by CLI Example on MySQL by GUI

To listen to MySQL course uses CLI:


[Link]
[Link]
To listen to MySQL course uses CLI and GUI:
[Link]
In our course, we will install MySQL based on XAMPP and we will RUN our MySQL
commands depending on Command Line Interface(CLI). This choice is because the popular
connections with MySQL from:
▪ Web page like that designed by PHP language
▪ Programs such as Python and Java
depend on the understanding of the MySQL commands written via Command Line
Interface(CLI).

MySQL Course in details in this link:


o [Link]
o [Link]
To write our MySQL sentences (or commands) based on Command Line Interface(CLI):

Step-1:
Download and Install XAMPP from the next link.
[Link]
It is preferred to install XAMPP on a drive rather than drive C because of windows security
restrictions with some MySQL commands.
Step-2:
Search on XAMPP Control Panel on your Computer. Then, click on it.
Step-3:
When XAMPP is openend, you will find a service (or server) called “Apache”. It works be
default on port number 80. May be, some application on your PC work with this poryt
number. So, we should this port number of Apache service.
On the window of XAMPP Control Panel, click of “Config”, then select “Apache ([Link])”
Step-4:
After the file of “Apache ([Link])” is openend, change the port number from the default
value 80 to another one. The popular free ports are 88 and 5000. We will Scroll the contenets
of the file down to find Listen 80. Then, change 80 to 88. Then, save the file.
Step-5:
on the window of XAMPP Control Panel, Start Apache and MySQL.

If the “Stop” button is reflected to be “Start” gain, try to change the port number again
to another value.
Step-6:
on the address bar of your browser, write: [Link]
Where 88 is our new port number of Apache. More details in this link:
[Link]
Step-7:
On “phpMyAdmin” Page, click in “SQL” tab:
Step-8:
Write your MySQL statements. Then Click on “GO” button.

Here, Write your MySQL statements.

Then Click on
“GO” button.
Example:

1st statement
USE MUST;
SELECT * FROM Registration; 2nd statement

Each statement can be


written in one line or more
but must be ended by “;”.

Click on
If there is an error to RUN the MySQL statements, then, the error will be shown below:
If there is no error:

1st statement is correct

2nd statement is correct

The Result
CREAT & INSERT
Create a Database
The syntax used to create a database:
CREATE DATABASE database_name;

Example:
Database name
Each statement must be ended by “;”
Hint: to delete the database, we can use:
DROP DATABASE INF405;

You must click on Go to RUN the sentence


statement is correct
statement
to see all the databases names in MySQL, we can use:
SHOW DATABASES;

statement is correct
statement

Result
If we create a database that created before, we will get an error as follows:

To avoid the error, we can use the following statement:


CREATE DATABASE IF NOT EXISTS INF405;
Create a Table in the Database
Database can contain more than one table. Each table can contain one column or more.
The syntax used to create a table:
CREATE TABLE table_name();

Example: To create the next table:


Code Name Email Tele
⁞ ⁞ ⁞ ⁞

USE INF405; “USE database_name” is used to refer to the


CREATE TABLE StudentInf( database that we will create the table in it.
code varchar(9),
varchar is the datatype. (9) means that maximum
Name varchar(50),
Email varchar(30),
number of characters in this column must be 9. We
Tele varchar(15) will discuss the datatypes soon.
); You should note that: the sentence of each column is
ended by “,” except the last one.
1st statement is correct
1st statement

2nd statement is correct


2nd statement

You can Create your table by GUI window from the next Link:
‫انشاء قاعدة بيانات‬mysql ‫باستخدام‬Xampp → [Link]
to see all the tables names in the database, we can use:
SHOW TABLES;

1st statement is correct

1st statement

2nd statement is correct


2nd statement

Result
If we create a table that created before, we will get an error as follows:

If You avoid this error, and use “IF NOT EXISTS” as follows:

MySQL will create the table if it does not exist. MySQL does not
override on the existing table.
As shown in the example, we change the “Name” column to be
“Address” column. MySQL will consider the old table without
change.
Insert data (called records) into the table
In the database, the columns are called “Fields” and the rows are called “Records”. Thus, in a
table, data are stored in fields and records. Here, we will insert records for one filed or more.
The syntax used to insert records in the fields:
INSERT INTO table_name VALUES();
Code Name Email Tele
Example: To insert the next data:
97909 Fawzy Khaled Mazen Fawzy@[Link] +201011000100

USE INF405;
INSERT INTO StudentInf
VALUES ('97909', 'Fawzy Khaled Mazen', 'Fawzy@[Link]', '+201011000100');

“VALUES” line can be written in the same line of “INSERT INTO” as follows:
INSERT INTO StudentInf VALUES ('97909', 'Fawzy Khaled Mazen', 'Fawzy@[Link]', '+201011000100');

or in different line as shown in the example. So, we do not add “;” except with “VALUES” line.
Although we remember the columns titles, we forget the order of them when we insert
the records, we can use specify the order of the records according to the order that we
specified in the MySQL sentence as follows:
The columns (or fields) titles
USE INF405;
INSERT INTO StudentInf (Email, Code, Tele, Name)
VALUES ('Fawzy@[Link]', '97909', '+201011000100', 'Fawzy Khaled Mazen');

These data (or records) are ordered according to the orders of columns
Code Name Email Tele
97909 Fawzy Khaled Mazen Fawzy@[Link] +201011000100

In MySQL:
If we want to enter the record (or data) for one column or more:
The columns (or fields)
USE INF405;
INSERT INTO StudentInf (Code, Name)
VALUES ('97909', 'Fawzy Khaled Mazen');

These data (or records) for specified columns and in order

Code Name Email Tele


97909 Fawzy Khaled Mazen NULL NULL
Datatypes in MySQL
In MySQL, datatypes can be classified into:
▪ Numeric datatypes
▪ String (character and byte) datatypes
▪ Date and Time datatypes
▪ Spatial datatypes
▪ JSON datatype.

We will talk about the first three datatypes. For more details about datatypes, in this link:
[Link]
Numeric Datatypes
a) Integers Values
Range
Type Description Digits
From To
Signed -2147483648 2147483647
INT Integer 11
Unsigned 0 4294967295
Signed -128 127
TINYINT Very small integer 4
Unsigned 0 255
Signed -32768 32767
SMALLINT Small integer 5
Unsigned 0 65535
Signed -8388608 8388607
MEDIUMINT Medium-sized integer 9
Unsigned 0 16777215
Signed -9223372036854775808 9223372036854775807
BIGINT Large integer 20
Unsigned 0 18446744073709551615
Example:
USE INF405;
CREATE TABLE doctors(
RoomNo TINYINT,
Salary INT,
TotalPatient BIGINT
);

So, maximum number of digits in the “RoomNo” column is 4 (e.g., 4512) because its datatype
is TINYINT as mentioned before in the last table. But we can limit this digits to any number of
digits less than the maximum number of digits, 4. This problem is for any datatype in MySQL.
For example:
RoomNo TINYINT(2),
In this case, the user cannot exceed than 2 digits (e.g., 62). If the user enters more that 2
digits, MySQL will return an error. This problem is for any datatype in MySQL.
b) Decimal Values
They cannot be unsigned. They take two parameters: M and D where M is total number of
digits including decimal while D is number of decimals. For example: FLOAT(5, 3) means that
3 is the number of decimals and 5 is the total number of digits (including decimals).

Decimal
Type Description Synonym Default
precision
FLOAT(M,D) A floating-point number. FLOAT(10,2) 24 places

DOUBLE(M,D) A double precision floating-point number. REAL DOUBLE(16,4) 53 places


Unpacked floating-point number. In the
DECIMAL(M,D) unpacked decimals, each decimal NUMERIC
corresponds to one byte
Example:
USE INF405;
CREATE TABLE products( So, maximum number of digits after decimal point is 2 and
price float(4, 2), total number of digits is 4 including decimal (e.g., 45.12).
Qunatity INT,
);
String Datatypes
a) CHAR

Type Description Length Note

A fixed-length (=M) string. right-


. Defining a length is not
CHAR(M) padded with spaces to the Up to 255 characters
required, but the default is 1.
specified length
VARCHAR(M) A variable-length string Up to 255 characters You must define the length
char(5) vs. varchar(5):
▪ In the case of char(5), the memory will save this string and add padding to the string until
the length reach 5. So, the size of the cell in the memory is 5 characters.
▪ In the case of varchar(5), the memory will save this string without adding padding to the
string. So, the size of the cell in the memory is as number of characters in the string without
padding but the record cannot be exceeded more than 5 characters. So, “varchar” is
preferred than “char” because of memory space.
Example:
USE INF405;
CREATE TABLE StudentInf(
code varchar(9),
Name varchar(50),
Email varchar(30),
Tele varchar(15)
);

Here, we selected datatype: “varchar”. It means that the data type of this column is String
and you can insert a record in each cell in this column from 0 character into 9 characters. If
you insert a record in this cell and the length is more than 9 characters, you will return an
error from MySQL and this record will not be added to the table.
b) BLOB
BLOBs are "Binary Large Objects" and are used to store large amounts of binary data, such
as images or other types of files. With BLOB, You do not specify a length.

Type Length
BLOB 65535 characters
TINYBLOB 255 characters
MEDIUMBLOB 16777215 characters
LONGBLOB 4294967295 characters
c) TEXT
With TEXT, You do not specify a length.
Type Length
TEXT 65535 characters
TINYTEXT 255 characters
MEDIUMTEXT 16777215 characters
LONGTEXT 4294967295 characters

d) ENUM
ENUM means enumeration ‫التعداد‬. When defining an ENUM, you are creating a list of items
from which the value must be selected (or it can be NULL).
For example, if you wanted your field to contain "A" or "B" or "C", you would define your
ENUM as ENUM ('A', 'B', 'C') and only those values (or NULL) could ever populate that field.
Date and Time Datatypes

Type Format Range Example

DATE YYYY-MM-DD 1000-01-01 and 9999-12-31 1973-12-30


TIME HH:MM:SS [Link]
1000-01-01 [Link] and
DATETIME YYYY-MM-DD HH:MM:SS 1973-12-30 [Link]
9999-12-31 [Link]
TIMESTAMP YYYYMMDDHHMMSS 19731230153000
The default length is 4.
YEAR(M) 2-digits YY 70 to 69 73
4-digits YYYY 1970 to 2069 1973
NOT Null & Default
If we do not insert a record for some cell, then MySQL will consider it as a Null value.
USE INF405;
INSERT INTO StudentInf (Code, Name)
VALUES ('67920', 'Hammd Tawfeek bazzar Lanwar');

Code Name Email Tele


97909 Fawzy Khaled Mazen Fawzy@[Link] +201011000100
67920 Hammd Tawfeek bazzar Lanwar NULL NULL

There are two constraints used to change this value:


▪ NOT NULL constraint
The NULL value will be removed
▪ DEFAULT constraint NULL NOT NULL DEFAULT
The NULL value will be replaced by default value NULL 10
NOT NULL constraint
If we want some cell be empty without Null value, we should specify “NOT NULL” constraint
for the column (or the field) when we create the table:
USE INF405;
CREATE TABLE StudentInf(
code varchar(9) NOT NULL,
Name varchar(50),
Email varchar(30),
Tele varchar(15)
);
USE INF405;
INSERT INTO StudentInf (Name, Email)
VALUES ('Khaled Hady Wamy', 'Khaled@[Link]');
Code Name Email Tele
97909 Fawzy Khaled Mazen Fawzy@[Link] +201011000100
67920 Hammd Tawfeek bazzar Lanwar NULL NULL
Khaled Hady Wamy Khaled@[Link] NULL

The cell is empty for “Code”, but “NULL” for “Tele”


DEFAULT constraint
The DEFAULT constraint is used to set a default value for a column. The default value will be
added to all new records, if no other value is specified.
In our example, we will assign “Name” column by DEFAULT constraint as follows:
USE INF405;
CREATE TABLE StudentInf(
code varchar(10),
Name varchar(50) DEFAULT 'Unknown Student',
Email varchar(30),
Tele varchar(15)
);
In our example, Null values in “name” will be replaced by “Unknow Student”.
Let us try to insert the next values without a record for “Name” column:
USE INF405;
INSERT INTO StudentInf (Code, Email, Tele)
VALUES ('986799', 'Wessam@[Link]', '+201087568758');

Code Name Email Tele


986799 Unknown Student Wessam@[Link] +201087568758
Unique & Auto Increment
UNIQUE constraint
The assignment of the column as unique means that no value can be repeated in this column.
With column creation, we should assign Unique constraint for the column. In our next
example, we will assign Unique constraint for the “code” column as follows:

USE INF405;
CREATE TABLE StudentInf(
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
UNIQUE (code)
);
Or you can assign Unique constraint in the same line of the “code” column as follows:

USE INF405;
CREATE TABLE StudentInf(
code varchar(10) UNIQUE,
Name varchar(50),
Email varchar(30),
Tele varchar(15)
);
Right now, we can insert our data in the table as follows:
USE INF405;
INSERT INTO StudentInf (Code, Name, Email, Tele)
VALUES
('87987', 'Khaled Hady Wamy', 'Khaled@[Link]', '+201567576565'),
('547657', 'Kazem Amir Madian', 'Kazem@[Link]', '+201278969796'),
('986799', 'Wessam Omar Mazen', 'Wessam@[Link]', '+201087568758');

Code Name Email Tele


87987 Khaled Hady Wamy Khaled@[Link] +201567576565
547657 Kazem Amir Madian Kazem@[Link] +201278969796
986799 Wessam Omar Mazen Wessam@[Link] +201087568758

If we try to insert a code that is inserted before, MySQL will consider an error in the statement.
USE INF405;
INSERT INTO StudentInf (Code, Name, Email, Tele)
VALUES
('547657', 'Marwan Jack Wafy', 'Marwan@[Link]', '+201193105219’);
We can assign more than one column:
USE INF405;
CREATE TABLE StudentInf(
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
UNIQUE (code, Email)
);

We can assign a name for Unique constraint. Here, we assign “Cairo” for Unique constraint.
USE INF405;
CREATE TABLE StudentInf(
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
CONSTRAINT Cairo UNIQUE (code, Email)
);
AUTO INCREMENT constraint
Auto-increment allows a unique number to be generated automatically when a new record is
inserted into a table started by 1.
STNum Code Name Email Tele
1 97909 Fawzy Khaled Mazen Fawzy@[Link] +201011000100
2 67920 Hammd Tawfeek bazzar Lanwar NULL NULL
3 Khaled Hady Wamy Khaled@[Link] NULL

If we assign some column by “AUTO_INCREMENT” constraint, we should understand that:


▪ Each table can have only one AUTO_INCREMENT column.
▪ This AUTO_INCREMENT column cannot be assigned by “DEFAULT” constraint to have a
default value.
▪ It must be defined as a key (not necessarily the PRIMARY KEY or UNIQUE key).
▪ If the AUTO_INCREMENT column is assigned as a primary key, we should understand that
the PRIMARY KEY constraint has the two constrains: UNIQUE and NOT NULL. It means
that Primary keys must contain UNIQUE values and cannot contain NULL values.
With column creation, we should assign the auto-increment column as a primary key:
USE INF405;
CREATE TABLE StudentInf(
StudNum int(10) AUTO_INCREMENT,
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
PRIMARY KEY (StudNum)
);
Or you can assign PRIMARY KEY constraint in the same line of the “StudNum” column as
follows:
USE INF405;
CREATE TABLE StudentInf(
StudNum int(10) AUTO_INCREMENT PRIMARY KEY,
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15)
);
Right now, we can insert our data in the table as follows:
USE INF405;
INSERT INTO StudentInf (Code, Name, Email, Tele)
VALUES
('87987', 'Khaled Hady Wamy', 'Khaled@[Link]', '+201567576565'),
('547657', 'Kazem Amir Madian', 'Kazem@[Link]', '+201278969796'),
('986799', 'Wessam Omar Mazen', 'Wessam@[Link]', '+201087568758');

STNum Code Name Email Tele


1 87987 Khaled Hady Wamy Khaled@[Link] +201567576565
2 547657 Kazem Amir Madian Kazem@[Link] +201278969796
3 986799 Wessam Omar Mazen Wessam@[Link] +201087568758

We do not insert any data for “STNum” column, but MySQL increment the cells starting from 1.
Also, from the last example, we understand how we can insert many rows at the same time.
We can rewrite the last example by another way. We do not need to write the columns names
but for the incremented column, we will insert NULL. MySQL will remove this NULL value by
the incremented value as follows:
We do not write the columns names here
USE INF405;
INSERT INTO StudentInf
VALUES
(NULL, '87987', 'Khaled Hady Wamy', 'Khaled@[Link]', '+201567576565'),
(NULL, '547657', 'Kazem Amir Madian', 'Kazem@[Link]', '+201278969796'),
(NULL, '986799', 'Wessam Omar Mazen', 'Wessam@[Link]', '+201087568758');

STNum Code Name Email Tele


1 87987 Khaled Hady Wamy Khaled@[Link] +201567576565
2 547657 Kazem Amir Madian Kazem@[Link] +201278969796
3 986799 Wessam Omar Mazen Wessam@[Link] +201087568758
We can assign a name for the primary Key. In our example, this key will be called “Cairo”.
USE INF405;
CREATE TABLE StudentInf(
StudNum int(10) AUTO_INCREMENT,
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
CONSTRAINT Cairo PRIMARY KEY (StudNum)
);
If we want the increment starts from another value rather than 1
USE INF405;
CREATE TABLE StudentInf(
StudNum int(10) AUTO_INCREMENT PRIMARY KEY,
code varchar(10),
Name varchar(50),
Email varchar(30),
Tele varchar(15),
)AUTO_INCREMENT=5;

We will specify the starting of the increment here

It is important to listen to this video:


[Link]
CHECK
The CHECK constraint is used to limit the value range that can be placed in a column.
USE INF405;
CREATE TABLE StudentInf(
Name varchar(50),
Age int(2),
Tele varchar(15),
CHECK (Age>=20 AND Age<=50)
);

USE INF405;
INSERT INTO StudentInf
VALUES
('Khaled', 71, '012896986');

This error because we insert a value for


the Age out of the available range.
The CHECK constraint can be used for more than one column as follows:
USE INF405;
CREATE TABLE StudentInf(
Name varchar(50),
Age int(2),
Tele varchar(15),
CHECK (Age>=20 AND Name!=NULL)
);

The CHECK constraint can be called by a name:


USE INF405;
CREATE TABLE StudentInf(
Name varchar(50),
Age int(2),
Tele varchar(15),
CONSTRAINT Cairo CHECK (Age>=20 AND Age<=50)
);
Query on the Table [SELECT Statement]
Query ‫االستعالم‬
‫ر‬
Query is any command used to retrieve data ‫الستداد البيانات‬ from a table. In Structured Query
Language (SQL), queries are almost always made using the SELECT statement.

To understand SELECT Statement, Let us create a database. Then, inside the database, we will
create a table:

To create a database :
CREATE DATABASE employee;
Let us assume the next table:

To create a table :
USE employee;
CREATE TABLE Persons(
Person_ID int(1) AUTO_INCREMENT,
Person_Name varchar(10),
Region varchar(20) DEFAULT 'Unknown Region',
Age int(2) NOT NULL,
Female int(1),
Male int(1),
Salary int(5),
PRIMARY KEY (Person_ID),
UNIQUE (Region),
CHECK (Salary>2000 and Age>20)
);
Insert the values:
USE employee;
INSERT INTO Persons
VALUES
(NULL, 'Kazem', 'Brazil', 21, 1, 0, 3000),
(NULL, 'Mazen', 'Japan', 29, 1, 1, 5375),
(NULL, 'Habib', 'France', 25, 2, 0, 6000),
(NULL, 'Yasser', 'Marco', 31, 0, 3, 32000),
(NULL, 'Shady', 'Canada', 23, 1, 2, 7200);
To do a query, we will depend on Select statement. Its syntax is as follows:
SELECT Column_names FROM table_name;

For example:
To select all columns from the table: “Persons”

USE employee;
SELECT * FROM Persons;

RESULT:

Report
To select specific columns from the table: “Persons”
USE employee;
SELECT Region, Salary FROM Persons;

RESULT:

Report
So, we depend on SQL language to send a query to MySQL Query ‫االستعالم‬
database. MySQL database will respond by a report.

Example on SQL language used to send a query: SQL MySQL


Language Database
USE employee;
SELECT * FROM Persons; Report ‫تقرير‬

Example on the report:


Project
Suggest data in a table. Then, Find MySQL statement that used
to insert the next values in a MySQL table? Then display them?

Hint: This project like Q3 in Section 01

You might also like