根据另一个表中的值更新一个表中的字段

编程入门 行业动态 更新时间:2024-10-26 12:35:08
本文介绍了根据另一个表中的值更新一个表中的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在一个表中有一个状态字段,在其中将测试步骤标记为pass或fail,并且在另一个表中,如果所有测试步骤(testID)均已完成,则我必须将测试用例(testID)更新为pass pass和fail测试用例,如果其中一个测试是fail.

I have a status field in a table in which test steps are marked as pass or fail and in another table I have to update test case(testID) as pass if all test step(testID) are pass, and fail test case if one of test is fail.

我在两个表中都有testID字段.

I have testID field common in both tables.

在第一个表中,一列是testID,对应于该测试ID的5个步骤,它们可以是pass或fail.

In the 1st table one column is testID and 5 steps are corresponding to that test ID and they can be pass or fail.

在第二个表中,我有一列,必须基于总共5个步骤将状态标记为pass或fail.

In the 2nd table I have one column in which I have to mark status as pass or fail based on overall 5 steps.

推荐答案

以下查询分两步执行更新:第一个查询更新存在并通过的那些测试,第二个查询更新存在并失败的那些测试.

The following queries perform the update in two steps: the 1st query updates those tests which exist and pass, and the 2nd query updates those tests which exist and fail.

update table1 t1 set t1.teststatus = 'pass' where t1.testID in ( select t2.testID from table2 t2 group by t2.testID having min(t2.status) = max(t2.status) and min(t2.status) = 'pass' )

更新失败"的测试:

update table1 t1 set t1.teststatus = 'fail' where t1.testID in ( select t2.testID from table2 t2 where t2.status = 'fail' group by t2.testID )

更多推荐

根据另一个表中的值更新一个表中的字段

本文发布于:2023-10-15 00:47:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!