Modificarea de informatii – Update

postat acum 4 ani de Stefanescu Mihai in categorie SQL

Comanda UPDATE este folosita pentru a modifica datele deja existente in baza de date.

Puteti folosi comanda UPDATE impreuna cu clauza WHERE pentru a modifica o anumita inregistrare din baza de date.

Sinataxa

Sintaxa de baza a acesteio comenzi este aceasta (impreuna cu clauza WHERE):

UPDATE nume_tabel
SET coloana1 = valoare1, coloana2 = valoare2...., coloanaN = valoareN
WHERE [conditia];

Exemplu:

Consideram urmatoprul tabel cu angajati drep exemplu:

+----+----------+--------+-----------+----------+
| ID | NUME     | VARSTA | ADRESA    | SALARIU  |
+----+----------+--------+-----------+----------+
|  1 | Ion      |  32    | Bucuresti |  4000.00 |
|  2 | Mircea   |  25    | Giurgiu   |  2500.00 |
|  3 | Vlad     |  23    | Sibiu     |  1000.00 |
|  4 | Daniel   |  25    | Cluj      |  3500.00 |
|  5 | David    |  27    | Chisiumau |  4500.00 |
|  6 | Gheorghe |  22    | Alexandria|  2500.00 |
|  7 | Alex     |  24    | Iasi      | 11000.00 |
+----+----------+--------+-----------+----------+

Mai jos am scris un query ce va updata inregistrarea cu ID-ul 6:

UPDATE angajati SET ADRESA = 'Buzau' WHERE ID = 6;

Daca vrei sa faci update tuturor adreselor si salariilor din tabel codul tau SQL va avea forma:

UPDATE angajati SET ADRESA = 'Bucuresti', SALARIU = 100000.00;

 

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group
Acest articol a fost mutat de pe vechea platforma.
Pentru orice eroare aparuta la mutare va rog sa ma contactati!

Comentariu postate de minecraft download la data de 14.05.2019
I was wondering if you ever considered changing the structure of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 pictures. Maybe you could space it out better?
Comentariu postate de download minecraft free la data de 15.05.2019
What's up mates, nice piece of writing and pleasant arguments commented at this place, I am genuinely enjoying by these.
Comentariu postate de minecraft download for free la data de 16.05.2019
I just like the helpful information you supply to your articles. I'll bookmark your blog and take a look at again here regularly. I am somewhat certain I'll be informed a lot of new stuff proper here! Best of luck for the next!
Comentariu postate de minecraft free download la data de 17.05.2019
Hey there! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips?