0

我有以下数据:

  PGM      INC        EXC
  First    A          AA
  First    B          BB
  First    C          CC
  First    D          DD

  Second   E          EE
  Second   F          FF
  Second   G          GG
  Second   H          HH

我现在想正确地更新将 PGM 列为 INC 值和 EXC 值的“First”映射值的“Second”的列。

我们该怎么做?

重新编辑:

我希望 PGM = 'Second' 的数据反映如下

  PGM      INC        EXC
  Second   E          AA
  Second   F          BB
  Second   G          CC
  Second   H          DD

也就是说,Second 的列应该以与保留在那里的值相同的方式反映列 First 的值。

4

1 回答 1

0

Didn'ty really understand your question but if i am right you want to update INC and EXCWHERE PGM is second . if this is the case

UPDATE `table_name` SET `INC` = 'new_value' , `EXC` = 'new_value' WHERE `PGM` = 'Second' 

This will update every row with PGM value 'Second' what i suggest you to do is make another field as id set is to be auto_increment and index it .

Then you can query like this

UPDATE `table_name` SET `INC` = 'new_value' , `EXC` = 'new_value' WHERE `PGM` = 'Second' && `id` = 'id_value'

However you can still query like this for additional conditions

UPDATE `table_name` SET `INC` = 'new_value' , `EXC` = 'new_value' WHERE `PGM` = 'Second' && `INC` = 'Old_value' && `EXC` = 'old_value'
于 2013-09-22T07:16:42.117 回答