메뉴 건너뛰기

tnt_db

MS-SQL Update ~ Select 구문 예제

구퍼 2008.10.31 09:59 조회 수 : 4701

* MSSQL *
UPDATE table_a
   SET table_a.column_a = table_b.column_b
  FROM table_a,
            table_b, 
 WHERE table_a.userid  = table_b.userid
 
 
* 오라클 *
UPDATE table_a
   SET column_a = column_b
 WHERE userid IN (SELECT userid
                    FROM b)
UPDATE table_a
   SET (column_1, column__2) = (SELECT column_a, column_b
                                  FROM table_b
                                 WHERE join_column_1 = table_a.join_column_a);
UPDATE table_a
   SET column_1 = (SELECT COLUMN
                     FROM table_b
                    WHERE userid = table_a.userid);
UPDATE table_a
   SET (column_1) = (SELECT COLUMN
                       FROM table_b
                      WHERE userid = table_a.userid AND url IS NOT NULL);
위로