选择两个值并更新

时间:2013-01-05 18:48:48

标签: mysql sql

我想SELECT id, some_complex_calculations FROM some_table然后更新some_table以将some_complex_calculations插入其他具有相应ID的列中。我该怎么办?

2 个答案:

答案 0 :(得分:1)

试试这个:

UPDATE some_table 
SET other_column = some_complex_calculations 
WHERE Id = 5; #appropiate ID

答案 1 :(得分:0)

如果我了解您的要求,那么这就是您想要的, UPDATE将替换现有行。但是你想要插入行,我想,

INSERT INTO SOME_TABLE(YOUR_OTHER_COLUMN) 
VALUES(SELECT some_complex_calculations FROM some_table WHERE ID=4) #For Example