Esküvő

MySQL Update Query

Update Syntax

UPDATE 'database' SET 'column_1_name' = 'value_1' WHERE 'column_2_name' = 'value_2'

To execute MySQL query in PHP is easy, write the following code and replace CODE with your MySQL query:

<?php mysql_query("CODE"); ?>

Update all rows

One of the previous articles I showed you how to create a MySQL database, insert and select rows. Now I show you how to update all rows in students table.

UPDATE 'students' SET gender = 'male'

Result

idfirst_namelast_namegender
1 Jack Daniels male 
2 Lara Croft male
3 Ronald McDonald male
4 Mickey Mouse male

Update one row

This will only effect one row, where id = 2 and only change data to female from male in gender column. All other rows remain the same.

UPDATE 'students' SET gender = 'female' WHERE id = '2'

Result

idfirst_namelast_namegender
1 Jack Daniels male 
2 Lara Croft female
3 Ronald McDonald male
4 Mickey Mouse male

Next to read

The next is article about MySQL Delete Query, learn how to delete rows from the database.


Esküvő


Related articles

Email Validation

Email Validation

08/02/2013

Learn how to validate email on client side with HTML5, Javascript and on server side with PHP.

Generate Thumbnail on the Fly with PHP

Generate Thumbnail on the Fly with PHP

04/02/2013

In a previous artice I already showed you how to generate square thumbnails with PHP. Now I show you how to keep the original ratio of the image and how to control the alignment of the square image.

Facebook Upload Photo to User′s Profile

Facebook Upload Photo to User′s Profile

31/01/2013

Learn how to upload a photo to Facebook user′s profile with PHP SDK via Graph API!


Leave a comment

We welcome any comment from you! Please keep in mind that comments are moderated and rel='nofollow' is in use. So, please do not use a domain as your name or a spammy keyword, or your comment will be deleted.

Name: *

E-mail: *

Message: *

Click on the lion *


Find us on Facebook

Tags

Esküvő

Back to Top