SQL UPDATE Statement

The SQL UPDATE statement is used to update or modify a record that already exists in a table.We can use WHERE clause with the update statement.

UPDATE Statement Syntax :

The syntax of the UPDATE statement is −

UPDATE table_name
SET column1 = value1, column2 = value2...., columnN = valueN
WHERE [condition];

In this, the value of column 1 will be modify to value 1, column 2 to value 2 and similar columnsN to valueN.



UPDATE Statement Example :

Consider the Customer table with the following records -

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
2 Vivaan 25 Mumbai 30000
3 Reyansh 28 Chennai 35000
4 Muhammad 24 Udaipur 50000
5 Sai 30 Mumbai 27000


TEST CASE 1 :- The following code is an example, which would modify the CustomerName and Address fields from Customer table where CustomerID = 4.

UPDATE Customer
SET CustomerName = 'Aadesh', Address= 'Mysore'
WHERE CustomerID = 4;


The result for the respective sql query is as follows −

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
2 Vivaan 25 Mumbai 30000
3 Reyansh 28 Chennai 35000
4 Aadesh 24 Mysore 50000
5 Sai 30 Mumbai 27000



TEST CASE 2:- The following code is an example, which would modify the CustomerName fields from Customer table where Address='Mumbai'

UPDATE Customer
SET CustomerName='Gaurav'
WHERE Address='Mumbai';


The result for the respective sql query is as follows −

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
2 Gaurav 25 Mumbai 30000
3 Reyansh 28 Chennai 35000
4 Muhammad 24 Udaipur 50000
5 Gaurav 30 Mumbai 27000





Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+601-601-1=0+0+0+1 --

pHqghUme
-1 OR 3+601-601-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+601-601) --

pHqghUme
-1 OR 3*2>(0+5+601-601) --

pHqghUme
-1 OR 2+45-45-1=0+0+0+1

pHqghUme
-1 OR 3+45-45-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+45-45)

pHqghUme
-1 OR 3*2>(0+5+45-45)

pHqghUme
-1' OR 2+789-789-1=0+0+0+1 --

pHqghUme
-1' OR 3+789-789-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+789-789) --

pHqghUme
-1' OR 3*2>(0+5+789-789) --

pHqghUme
-1' OR 2+91-91-1=0+0+0+1 or 'iPDbqM9U'='

pHqghUme
-1' OR 3+91-91-1=0+0+0+1 or 'iPDbqM9U'='

pHqghUme
-1' OR 3*2<(0+5+91-91) or 'iPDbqM9U'='

pHqghUme
-1' OR 3*2>(0+5+91-91) or 'iPDbqM9U'='

pHqghUme
-1" OR 2+654-654-1=0+0+0+1 --

pHqghUme
-1" OR 3+654-654-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+654-654) --

pHqghUme
-1" OR 3*2>(0+5+654-654) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
MPxkaTnG'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 551=(SELECT 551 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 336=(SELECT 336 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 240=(SELECT 240 FROM PG_SLEEP(15))--

pHqghUme
rtUU8FNg' OR 67=(SELECT 67 FROM PG_SLEEP(15))--

pHqghUme
ea3dZjW7') OR 728=(SELECT 728 FROM PG_SLEEP(15))--

pHqghUme
hokRqgaE')) OR 403=(SELECT 403 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@1ICmY

pHqghUme
555

pHqghUme
555

pHqghUme
555