1
有两种表,还有两个列是他们怎样写SQL在以下情况下
之间
table1:
id, date
table2:
id, date
同样的问题是,如何更新表2的ID,可以匹配的日期2表,这意味着,例如
update table2 set table2.id = table1.id Where table1.date = table2.date
感谢
有两种表,还有两个列是他们怎样写SQL在以下情况下
之间
table1:
id, date
table2:
id, date
同样的问题是,如何更新表2的ID,可以匹配的日期2表,这意味着,例如
update table2 set table2.id = table1.id Where table1.date = table2.date
感谢
update t2 set t2.id = t1.id
from table2 t2
inner join table1 t1 on t1.date = t2.date
Edit
update t2 set t2.id = t1.id
from table2 t2
inner join table1 t1 on t1.date = t2.date
where convert(date,t2.date)>'2013/01/01' --YYYY/MM/DD if your Date column is datetime.
抱歉,但设置t2.id = t2.id? – user782104
@ user782104错误**':)'** – Luv
如何添加一个条件,其中t2.date> xxx? – user782104