Ad Code

Responsive Advertisement

SQL UPDATE

 SQL UPDATE 







La commande UPDATE permet d'effectuer des adjustments sur des lignes existantes. Très souvent cette commande est utilisée avec WHERE pour spécifier sur quelles lignes doivent watchman la ou les adjustments.


The SQL UPDATE command updates data from a table in a MySQL, PostgreSQL, and so forth database 

This command allows us to modify the data stored in a table by replacing old new standard data. 

Updating data in a database is one of the basic and in addition to common operations that will be performed when controlling database data in the same way as selecting with the SQL SELECT command or inserting with SQL INSERT. 


SQL UPDATE will allow us to update family members data to one or more entries of an upset in a database. We will often use this command with WHERE to update only entries that defer to a certain criterion.


The SQL UPDATE Statement

 

The SQL UPDATE command allows you to update, that is, to change the information contained in a table in a database. 


We will be able to use this command to update the values of all entries for one or more columns or to update only the values of certain entries that meet a standard defined criterion, a WHERE provision. 


Update the values of all entries for one or more columns 


For starters, we'll be able to use the SQL UPDATE command to update the values of all entries for one or more columns. 


In this case, we will use the UPDATE syntax nom_de_table SET nom_colonne 'new value' to update the values of all "Table_Name" table entries for the "nom_colonne" column or the UPDATE syntax nom_de_table SET ' Column 1 ' new value 1', Column 2 'new value 2' to update the values of all entries for the "Column 1" and "Column 2" columns. 


Update the values of one or more entries for one or more columns with SQL UPDATE and WHERE 


Often, we will only want to update the values of one or more entries in our table that meet a certain criteria. In this case, we will use the SQL UPDATE command with a WHERE provision. 


So we're going to use the following syntax: UPDATE Table_Name SET Column_Name new value' WHERE condition. 


To update the values of a single entry, standard example, you can use the id column of the table if it contains one by specifying UPDATE Table_Name SET Column_Name 'new value' WHERE id - number.


UPDATE Syntax : 


UPDATE table_name
SET column1 = 'value1' , column2 = 'value2', ...
WHERE condition;



Example : 


Consider the CUSTOMERS table having the accompanying records 

+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | Country   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ayoub    |  32 | Morocco   |  200.00 $|
|  2 | Alphred  |  25 | Germany   |  150.00 $|
|  3 | Xavi     |  23 | Spain     |  200.00 $|
|  4 | Comara   |  25 | Mali      |  609.00 $|
|  5 | Joen     |  27 | UK        |  800.00 $|
|  6 | lousey   |  22 | Canada    |  400.00 $|
|  7 | jack     |  24 | USA       | 1000.00 $|
+----+----------+-----+-----------+----------+


.The accompanying inquiry will refresh the ADDRESS for a client whose ID number is 6 in      the table


SQL> UPDATE CUSTOMERS
SET Country = 'Germany' and Age = '19'
WHERE ID = 6;













Post a Comment

1 Comments

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)