drqyxkzbs21968684 2012-04-26 19:02
浏览 383

MySql - 根据另一列的值更新某些行的列值

Well i have a situation, which i will explain with an example below

Column 1 Column 2 Column 3

   1       87       0
   6       89       0
   8       87       1
   9       87       0
  15       89       0
  18       90       1

so i have a case such that, the column3 value is unique for the same values of column2

so here lets consider column2 value as 87. So we have 3 such records, but i want a unique value for these three records in column3. So i mean there should be only one of these three records to have the value 1 in column3 and the rest should be having it as 0.

So lets say i want to update the value of column3 for these set of records to 1, where the column1 value is 9 and set the value of column3 to 0 when the column1 value is 8 and column2 value is 87. So i am unable to figure out how to do this.

I tried by resetting all the column3 values to 0 if the column2 value is 87 and then update the particular required record. But that's not happening. Any other possible solution??

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教