MySQL_Insert_Update and Delete- Tutorialpath

Inserting, updating, and deleting data in MySQL

Welcome to all our readers on our website at www.tutorialpath.com. As you all know that here on our website we will provide you lots of information related to the latest and newly introduced technology which help you to get updated with the latest tech. Here you will get all the useful information which is required in this tech world. As you know technology is one of the trending part in this world. So, here again we came up with a latest and new tech information which is related to the process of creating mysql insert update and delete. With the help of this article you will get to know the complete process of how to create mysql insert update and delete function in a step by step manner. So, simply have a look to this article and grab all the useful information which is going to be very helpful for you.

In this part of the MySQL tutorial, we will insert, update and delete data from MySQL tables. We will use the INSERT, DELETE and UPDATE statements.

These statements are part of the SQL Data Manipulation Language, DML.

PHP MySQL Insert Query

The INSERT INTO statement is used to add new records to a database table.

The insert statement is used to add new records to a database table. each time a new record is to be added we use INSERT INTO statement for that purpose.

There are two ways of inserting records either explicitly providing the column name with values respectively or simply by providing values of table but doesn’t specify the column name.

Syntax

Example:

In the previous chapter we created a table named “empInfo”, with four columns; “emp_id”, “name”, “emailid” and “mobile”. Use the same table to insert values inside empInfo table.

HTML Form

PHP MySQL Update Query

The update keyword is basically used to modify or edit the existing records in the database table.
it usually need a where clause to find out in which record change is to be done.

It is must to specify the where clause otherwise all records of that table got modify.
Syntax

Note : Notice the WHERE clause in the UPDATE syntax is must otherwise all records will be updated!

Example

Previous records in empInfo table are:

This example updates some data in the “empInfo” table

In the above example ,
empInfo table has 3 records of devesh,deepak, and ravi.
we need updation in this table as
devesh change to dev and his mobile number also need to be changed.

here first we create connection with the database,then database is selected using mysql_select_db(),
then update query is passed to the mysql_query( ) and the database table is updated.

PHP MySQL Delete

DELETE keyword is used basically to delete 1 or more than one records from the database table.even if we delete each and every row of a table then also the schema of the table remain un deleted. It,s necessary to use where clause in delete query, otherwise all the records will be deleted.

Syntax

Note : Notice the WHERE clause in the DELETE syntax is must otherwise all records will be deleted!

Example:

Previous records in empInfo table are:

This example deleted one row from “empInfo” table

After deletion , the “empInfo” table will look like this:

In the above example ,
empInfo table has 3 records of devesh,deepak, and ravi.
we need to delete a record from this table.
The record of devesh here is to be deleted.

here first we create connection with the database,then database is selected using mysql_select_db(),
then delete query is passed to the mysql_query and the table row is deleted.

So, as of now we had shared all the useful information related to MySQL INSERT UPDATE & DELETE which will going to very helpful for you. This article will help you to understand all the details and steps in a proper manner. Also, if you like this article then simply share this article with others as well so that they also understand all the details and information easily. On the other side, if you find any error in this article or if you have any query related to this article then simply drop a comment in the comment section below so that we will get to know that what issue you are facing and also we can reply to your query instantly.

One thought on “MySQL_Insert_Update and Delete- Tutorialpath

Leave a Reply

Your email address will not be published.