dongyun8075 2017-07-12 02:12 采纳率: 100%
浏览 119

根据表中其他列之间的计算值返回MySQL单元格值

I have a MySQL Table which is structured like so:

    key    ID    value1    value2
   | 1 | | ID1 |  |2|       |4|
   | 2 | | ID2 |  |5|       |5|
    .
    .
    .

I need to query this table and return just the IDs based on ascending order of the difference between value1 and value 2. If there are equal values then the ID order is irrelevant and can be random. The format of the output is important though. It should be a long string separated by the shown tokenizer. I have:

    $query = "Select * From `Table`";
    $result = $conn->query($query),

    while($row = $result->fetch_assoc()) {

    code???

    echo $row["ID"]."!@#$";
    }

How can I structure the missing code block to accomplish this? I think what I want to do is create a variable which is (value1 - value2) then create an array which stores the id as a key with the result and sort ascending then echo the key. I just don't know how to write it

  • 写回答

1条回答 默认 最新

  • duanjiao5543 2017-07-12 02:17
    关注

    Have a look at this - PHP MySQL Multi Query

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?