Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql update multiple rows

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

sql update multiple columns from another table

-- Oracle
UPDATE table2 t2 SET (VALUE1, VALUE2) = 
    (SELECT COL1 AS VALUE1, COL1 AS VALUE2 FROM table1 t1 WHERE t1.ID = t2.ID);
-- SQL Server
UPDATE table2 t2 SET
    t2.VALUE1 = t1.COL1,
    t2.VALUE2 = t1.COL2
FROM table1 t1
INNER JOIN t2 ON t1.ID = t2.ID;
-- MySQL
UPDATE table2 t2 INNER JOIN table1 t1 USING (ID)
SET T2.VALUE1 = t1.COL1, t2.VALUE2 = t1.COL2;
Comment

sql server update multiple columns at once

UPDATE Person.Person
 Set FirstName = 'Kenneth'
    ,LastName =  'Smith'
 WHERE BusinessEntityID = 1
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

sql server alter multiple columns

ALTER TABLE tblcommodityOHLC alter column CC_CommodityContractID NUMERIC(18,0);
ALTER TABLE tblcommodityOHLC alter column CM_CommodityID NUMERIC(18,0);
Comment

PREVIOUS NEXT
Code Example
Sql :: insert query in sql 
Sql :: like in postgresql 
Sql :: sql update 
Sql :: mysql select or insert current datetime 
Sql :: Expression number 1 of select list is not in group by clause 
Sql :: mysql disable triggers 
Sql :: Add new column T-SQL 
Sql :: postgres parent and child tables 
Sql :: oracle error compilation line 
Sql :: mysql in 
Sql :: mysql function to remove multiple spaces from the string 
Sql :: sql select all tables from database change url 
Sql :: find a column by name in a sql server table 
Sql :: case insensitive sql 
Sql :: create table with float datatype in sql server 
Sql :: mysql grant user permissions 
Sql :: psql check tables command 
Sql :: postgresql where and 
Sql :: Add a new column into table 
Sql :: mysql last friday of current month 
Sql :: sql server remove 0 from left 
Sql :: remove all spaces from string sql 
Sql :: mysql filter by date mount 
Sql :: postgresql variable in query 
Sql :: sql where is not number 
Sql :: how to get information about data types in postgreSQL 
Sql :: ORACLE CALL BACK TRACE 
Sql :: oracle list chain steps 
Sql :: python sqlalchemy orm to select null values 
Sql :: order by with where clause in mysql 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =