有 两个表,资产表:PropertyTable,合同表:ContractTable
1.资产表:PropertyTable有4个列,Number1(主键),city(城市),road(所在路段),address(门牌号)
2.合同表:ContractTable有3个列:city(城市),road(所在路段),address(门牌号)
问题是:我现在想给ContractTable增加一个列,列名Number2,再根据:
PropertyTable.city+PropertyTable.road+PropertyTable.address=
ContractTable.city+ContractTable.road+ContractTable.address的条件,给Number2添加上相应的Number1的值。
请问该如何写呢?
------解决方案--------------------
- SQL code
alter table ContractTable add colcumn Number2 int nullupdate ContractTableset Number2=PropertyTable.Number1from PropertyTable,ContractTablewhere PropertyTable.city+PropertyTable.road+PropertyTable.address=ContractTable.city+ContractTable.road+ContractTable.address