0% found this document useful (0 votes)
3 views48 pages

MySQL With PHP

The document provides an overview of SQL, a domain-specific language for managing relational databases, highlighting its capabilities such as defining data structure, querying, and modifying data. It focuses on MySQL as an open-source RDBMS that adheres to SQL standards and is commonly used in web applications. Additionally, it outlines various SQL commands and operations, including creating databases, inserting and selecting data, and performing joins and aggregate functions.

Uploaded by

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

MySQL With PHP

The document provides an overview of SQL, a domain-specific language for managing relational databases, highlighting its capabilities such as defining data structure, querying, and modifying data. It focuses on MySQL as an open-source RDBMS that adheres to SQL standards and is commonly used in web applications. Additionally, it outlines various SQL commands and operations, including creating databases, inserting and selecting data, and performing joins and aggregate functions.

Uploaded by

jumpyturtle8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

Server Side

Scripting
Using MySQL with PHP
Introduction to SQL
SQL is a domain-specific language used to manage and manipulate relational
databases. It provides a standardized way to interact with databases,
allowing users to define, query, modify, and manage the structure and data
within a relational database management system (RDBMS).

Capabilities:
• Defines the structure of data within a database.
• Performs queries to retrieve specific information from the database.
• Modifies data in the database, including insertion, updating, and deletion.
• Specifies security constraints and access permissions.

SQL is used in all relational databases such as MySQL, Oracle, MSSQL,


PostgreSQL etc. And, the major SQL commands are similar in all of them.
However, in some cases, those SQL commands may differ.
MySQL
• MySQL is an open-source relational database management system.
• It is a software application that facilitates the creation, modification, and
extraction of data from relational databases.
• MySQL follows the SQL standard for interacting with databases.
• Used in conjunction with other technologies to build database-driven
applications, and it is a component of the LAMP stack (Linux, Apache,
MySQL, PHP).
• Widely adopted and used by popular websites and applications for data
storage and retrieval.
Create a MySQL Database
Create a MySQL Database - Example
Connect to a Database
Create a table
Create a table - Example
Insert Data
Insert Data - Example
Select Data
Select Data
Where Clause
Where Clause - Example
Update
Update - Example
Delete Row(s)
Delete Row(s) - Example
Delete Table
Delete Database
Order By
Order By - ASC
Order By - DESC
Order By - Example
Aggregate Functions - MAX() & MIN()

Similarly, MIN() command would return the smallest value


from the age column.
Aggregate Functions - SUM()
Aggregate Functions - AVG()
Aggregate Functions - COUNT()
Aggregate Functions - Example
Group By
Group By - Example
Subquery
Subquery - Example
Subquery
Subquery - Another Example
Step I: Create 2 tables (products and orders) Step II: Add records to
those tables
Subquery - Another Example (...
Continued)
Step III: Use subquery to select products that have been ordered
Subquery - Another Example (...
Continued)
Step III: Use subquery to select products that have been ordered
JOIN / INNER JOIN
LEFT JOIN / LEFT OUTER JOIN
RIGHT JOIN / RIGHT OUTER JOIN
OUTER JOIN / FULL OUTER JOIN

Note: MySQL actually does not support this SQL


See the next page for it’s MySQL Workaround.
syntax.
OUTER JOIN / FULL OUTER JOIN (In MySQL)
CROSS JOIN / CARTESIAN JOIN
TYPES OF JOIN - SUMMARY
JOIN - Example
Step I: Create 2 tables (products and orders) Step II: Add records to
those tables
JOIN - Example (... Continued)
Step III:
JOIN - Example (... Continued)
Result:
Thank you!

You might also like