Presentation is loading. Please wait.

Presentation is loading. Please wait.

 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.

Similar presentations


Presentation on theme: " MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications."— Presentation transcript:

1

2  MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications  MySQL is very fast, reliable, and easy to use  MySQL supports standard SQL  MySQL is free to download and use  MySQL is developed, distributed, and supported by Oracle Corporation  MySQL is named after co-founder Monty Widenius's daughter: My  Structured Query Language

3  The data in MySQL is stored in tables.  A table is a collection of related data, and it consists of columns and rows.  Databases are useful when storing information categorically.  A company may have a database with the following tables: ◦ Employees ◦ Products ◦ Order

4  A query is a question or a request.  We can query a database for specific information and have a record set returned.  Look at the following query (using standard SQL):  SELECT LastName FROM Employees

5  Before we can access data in a database, we must open a connection to the MySQL server.  In PHP, this is done with the mysqli_connect() function.  mysqli_connect(host,username,password,dbname);

6  The connection will be closed automatically when the script ends.  To close the connection before, use the mysqli_close() function: 

7  The CREATE DATABASE statement is used to create a database in MySQL.  We must add the CREATE DATABASE statement to the mysqli_query() function to execute the command.

8

9  The CREATE TABLE statement is used to create a table in MySQL.  We must add the CREATE TABLE statement to the mysqli_query() function to execute the command.

10

11  $sql = "CREATE TABLE Persons ( PID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(PID), FirstName CHAR(15), LastName CHAR(15), Age INT )";

12  The INSERT INTO statement is used to add new records to a database table.  It is possible to write the INSERT INTO statement in two forms.  INSERT INTO table_name VALUES (value1, value2, value3,...)  INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)

13

14  Firstname: Lastname: Age:

15

16  The SELECT statement is used to select data from a database.  SELECT column_name(s) FROM table_name  To get PHP to execute the statement above we must use the mysqli_query() function.

17  "; } mysqli_close($con); ?>

18  The WHERE clause is used to extract only those records that fulfill a specified criterion.  SELECT column_name(s) FROM table_name WHERE column_name operator value

19  "; } ?>

20  The ORDER BY keyword is used to sort the data in a recordset.  The ORDER BY keyword sort the records in ascending order by default.  If you want to sort the records in a descending order, you can use the DESC keyword.  SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC

21  It is also possible to order by more than one column.  When ordering by more than one column, the second column is only used if the values in the first column are equal.  SELECT column_name(s) FROM table_name ORDER BY column1, column2

22  The UPDATE statement is used to update existing records in a table.  UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value  Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records should be updated. If you omit the WHERE clause, all records will be updated!

23  The DELETE FROM statement is used to delete records from a database table.  DELETE FROM table_name WHERE some_column = some_value  Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!

24  Thanks


Download ppt " MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications."

Similar presentations


Ads by Google