我有2個表TEST1和Test1Update用以下結構得到兩個相同的表中的記錄與某些條件
Test1
id name address
Test1Update
id name address
這裏Test1的是舊錶和Test1Update只是Test1的表 的副本我想用GET記錄此條件下,
if(Test1.id=Test1Update.id){
select macthing values from Test1Update tables,and remaining unmatched values from Test1 table
}
else if(Test1.id!=Test1Update.id)
{
select * from Test1 only
}
作爲示例
測試1具有數據等
Test1
id name address
1 john Ca
2 mary La
and Test1Update has data like
id name address
1 john Las Vega
小號
現在,我想只有從
Test1 table so final output will be
id name address
1 john Las Vegas
2 mary La
匹配從Test1Update表中的記錄和所有不匹配的記錄,這意味着,只要有發現任何匹配 舊條目應該replced與Test1Update。
我該如何使用select查詢或過程來做到這一點?
給我一些方法。
事實上你想選擇test1update表的值,除非它們與test1表的值不同? –
闡述更多,update_table是否包含表的所有行以及一些新行? –
我試圖用例子來闡述我的問題 – Java