我有以下两张表:
table1是tracsName,tracsid,N,NE...,table2是Tracs,kode,N2...。我想用这个代码用N2值更改N值,N和更多的是风箭头
更新查询,可以更简单吗?UPDATE table1 SET N=(select N2 from table2 where tracs='daraname2' AND kode='1-6'), NE=(select NE2 from table2 where tracs='daraname2' AND kode='1-6'), E=(select E2 from table2 where tracs='daraname2' AND kode='1-6'), SE=(select SE2 from table2 where tracs='daraname2' AND kode='1-6'), S=(select S2 from table2 where tracs='daraname2' AND kode='1-6'), SW=(select SW2 from table2 where tracs='daraname2' AND kode='1-6'), W=(select W2 from table2 where tracs='daraname2' AND kode='1-6'), NW=(select NW2 from table2 where tracs='daraname2' AND kode='1-6') WHERE tracsName='daraname2' AND tracsid='1-6'
我有一个错误,如果你能给我的逻辑或代码,它将是伟大的。
发布于 2015-10-07 04:20:08
以下是mysql的通用语法
UPDATE TABLE1 a
JOIN TABLE2 b ON a.name1 = b.name2
SET a.n1 = b.n2下面是sql server的示例
UPDATE a
SET n1 = b.n2
FROM TABLE1 a
JOIN TABLE2 b ON a.name1 = b.name2发布于 2015-10-07 04:14:16
试试这段代码
UPDATE table1
SET table1.N = table2.n
FROM table2 WHERE name2 = name1 https://stackoverflow.com/questions/32983574
复制相似问题