在同一个mysql语句中选择和更新mysql中的表

时间:2017-01-06 11:38:30

标签: mysql

我有mysql查询: -

select id,CustomerName, Scenario,StepNo,InTransit,IsAlef,Min(RunNo) as run,IsDominant,IsActive from RequestInfo
group by CustomerName, Scenario,StepNo,InTransit,IsAlef,RunNo 
having concat(CustomerName,Scenario,StepNo,InTransit,IsAlef,count(RunNo)) in
(select concat(CustomerName,Scenario,StepNo,InTransit,IsAlef,Min(Total)) from
(select CustomerName, Scenario,StepNo,InTransit,IsAlef,RunNo, count(RunNo) Total from RequestInfo
group by CustomerName, Scenario,StepNo,InTransit,IsAlef,RunNo
) b 
group by CustomerName, Scenario,StepNo,InTransit,IsAlef);

给出输出: -

   +------+--------------+--------------+--------+-----------+--------+------+------------+----------+
   | id   | CustomerName | Scenario     | StepNo | InTransit | IsAlef | run  | IsDominant | IsActive |
   +------+--------------+--------------+--------+-----------+--------+------+------------+----------+
   |    1 | Cleartrip    | SearchFlight | 1      | No        | No     | 1    | NULL       | NULL     |
   |  327 | HotStar      | SearchTv     | 1      | No        | No     | 1    | NULL       | NULL     |
   |  836 | NDTV         | LiveTv       | 1      | No        | No     | 2    | NULL       | NULL     |
   | 1090 | YATRA        | SearchFlight | 1      | No        | No     | 2    | NULL       | NULL     |
   +------+--------------+--------------+--------+-----------+--------+------+------------+----------+

我想将最后两列设置为"是"仅适用于上述结果中显示的行。

0 个答案:

没有答案