MySql:
UPDATE TableA
INNER JOIN tableB ON TableA.ITEMNO = tableB.ITEMNO
SET TableA.column1 = tableB.column1,
TableA.STATUS = IFNULL(
tableB.ITEMSTATUS,
'ITEMSTATUS'
)
WHERE
ID = 'ID'
AND IFNULL(TableA.ITEMNO, '') <> ''
AND IFNULL(TableA.column1, '') = ''
Sql Server:
UPDATE TableA
SET TableA.column1 = tableB.column1,
TableA. STATUS = ISNULL(
tableB.ITEMSTATUS ,'ITEMSTATUS'
)
FROM
TableA
INNER JOIN tableB ON TableA.ITEMNO = tableB.ITEMNO
WHERE
ID ='ID'
AND ISNULL(TableA.ITEMNO, '') <> ''
AND ISNULL(TableA.column1, '') = ''
- 12
下面是MySql更新语法
1、单表的UPDATE语句
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]
[ORDER BY ...]
[LIMIT row_count]
- 1
- 2
- 3
- 4
- 5
2、多表的UPDATE语句
UPDATE [LOW_PRIORITY] [IGNORE] table_references
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_definition]
- 1
- 2
- 3
作者:jiankunking 出处:http://blog.csdn.net/jiankunking