MySQL Tutorial: Managing MySQL data

Posted by

MySQL Tutorial: Managing MySQL data

MySQL Tutorial: Managing MySQL data

Insert Into SQL – Add Data

Once you have created table when you need to add up data into it.If you are using phpMyAdmin which will manually enter information. First click on “people”, the name of your table listed on to the left hand side. Then on to the right hand side, click on to the tab so called as “insert” and type the data.

You can now view work by clicking on to people and then onto browser tab. This is the best way to add data from query window is said to click on SQL icon on to phpmyadmin or on command line by typing:

INSERT INTO people VALUES ( "Jim", 45, 1.75, "2006-02-02 15:35:00" ), ( "Peggy", 6, 1.12, "2006-03-02 16:21:00" ) 

This helps to insert data into table “people” in order shown. If you unsure what order that fields are stated to be in database are where you can use this line:

INSERT INTO people (name, date, height, age) VALUES ( "Jim", "2006-02-02 15:35:00", 1.27, 45 ) 

Here you can tell about the database of the order as we are sending up the values and then add actual values.

SQL Update Command – Update Data

Its necessary to change data to your database. Lets start using phpMyadmin by clicking on to your database on to the left and choose to browse on to the right which means EDIT. Click on to pencil. You can now update information below. You must also go for command line or query. You must be careful when updating records and double check about your syntax which is easy on overwrite several records.

 UPDATE people SET age = 7, date = "2006-06-02 16:21:00", height = 1.22 WHERE name = "Peggy" 

What does this update that the table “people” by setting up new values for age, height and date. Important part of this command is WHERE that insure informaton which is updated for Peggy and not for every user in the database.

SQL Select Statement – Searching Data

In our test database we have two entires and everything which is easy in finding as a datab ase to grow as its useful to quickly search information. From phpMyAdmin you can now select your database then click on to search tab. The above example on how to search for all users under 12 years old.

In our example database this only returned one result, Peggy. To do this same search from query window or command line we type in:

SELECT * FROM people WHE*(all columns) from the “people” table WHERE the “age” field is a number less than 12.RE age < 12

What this does which is to SELECT to see names of people who are under 12 year old we could run instead:


 SELECT name FROM people WHERE age < 12 

SQL Delete Statement – Removing Data

You must need to remove old information from your database. You must be very careful on doing this as its gone once. When you are in phpMyAdmin, where you can remove information in many number of ways. First select the database ont to the left. One way to remove entries by choosing browser tab on right. Next to each entry which will see a red X. Click on the X will remove entry or delete multiple entires to check boxes on to the far left and hit red X at the bottom of page.


DELETE FROM people WHERE age < 12 

If the table is no longer needed where you can remove the entire table by clicking on the “Drop” tab in phpMyAdmin or running this line:

 DROP TABLE people 

Leave a Reply

Your email address will not be published. Required fields are marked *