Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql update multiple columns

UPDATE table_name SET column1=value1, column2=value2 WHERE condition
Comment

update multiple columns in sql

UPDATE table-name SET column-name = value, column-name = value WHERE condition = value
Comment

update table sql multiple set

-- CANT do multiple sets but can do case
UPDATE table
SET ID = CASE WHEN ID = 2555 THEN 111111259 
              WHEN ID = 2724 THEN 111111261
              WHEN ID = 2021 THEN 111111263
              WHEN ID = 2017 THEN 111111264
         END
WHERE ID IN (2555,2724,2021,2017)
Comment

sql update multiple tables

/*You can't update multiple tables in one statement,
however, you can use a transaction to make sure that
two UPDATE statements are treated atomically.
You can also batch them to avoid a round trip.*/


BEGIN TRANSACTION;

UPDATE Table1
  SET Table1.LastName = 'DR. XXXXXX' 
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '011008';

UPDATE Table2
SET Table2.WAprrs = 'start,stop'
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '011008';

COMMIT;
Comment

Update Multiple Rows

UPDATE Customers
SET country = 'NP'
WHERE age = 22;
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql how to use FIND_IN_SET function in WHERE clause ? 
Sql :: create table with timestamp postgresql 
Sql :: function in postgresql 
Sql :: mysql add to value 
Sql :: sql query to check if column contains alphabets 
Sql :: insert into auto increment mysql 
Sql :: mysql not equal 
Sql :: install mysql 5.7 ubuntu 20.04 
Sql :: postgres data location 
Sql :: run function in sql 
Sql :: add foreign key to existing table postgres 
Sql :: there is no unique constraint matching given keys for referenced table 
Sql :: how to truncate foreign key constraint table 
Sql :: Write an SQL query to print details of the Workers whose SALARY lies between 100000 and 500000. 
Sql :: sql values to array of objects 
Sql :: date get month number sql 
Sql :: select all tables linked server sql 
Sql :: oracle create package body 
Sql :: ms sql print more than 1 variable 
Sql :: postgre query date 
Sql :: reset postgres table index to next max value 
Sql :: sql remove check constraint 
Sql :: oracle pl/sql package 
Sql :: delete table in mysql 
Sql :: using distinct and count together in sql 
Sql :: best sql collation 
Sql :: sql composite key 
Sql :: t-sql add column 
Sql :: mysql dump 
Sql :: sql server select rows by distinct column 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =