如何比较两个不同表的两个不同行?

时间:2022-05-15 20:22:35

Im having two different tables Value(queid, m) and Ans(queid1, an). I want to compare queid and queid1 and if they are same then m and an's values and has to update the third table with correct values. Thanx a tons.
Table structures are
Value table will have two attributes queid and m. queid will have data like 3, 4, 5, 6, and m will have a, v, d, e
Ans table will have attributes queid1 and an. queid1 attributes will have data like 3, 4, 3, 4, 3, 3, 3, 2, 3, 4 and an will have data like a, v, a, a, a, c, e, r, e, d.
Now what i want is that it should compare the values of queid with queid1. so if we consider 3 ie first value of queid in value table, then it should find all the 3's in ans table and then is should compare a (ie the row corresponding to 3 in value table) with all the 3's in ans. And the corresponding right comparison of a's is to be stored in some third table.

我有两个不同的表值(queid,m)和Ans(queid1,an)。我想比较queid和queid1,如果它们相同,那么m和一个值,并且必须用正确的值更新第三个表。 Thanx一吨。表结构是Value表,它有两个属性queid和m。 queid会有3,4,5,6这样的数据,m会有一个,v,d,e的Ans表会有属性queid1和an。 queid1属性将包含3,4,3,4,3,3,3,2,3,4等数据,并且将具有a,v,a,a,a,c,e,r,e,d等数据。现在我想要的是它应该比较queid和queid1的值。因此,如果我们在值表中考虑3即queid的第一个值,那么它应该找到ans表中的所有3个,然后应该比较a(即值表中对应于3的行)和ans中的所有3个。并且a的相应的正确比较将存储在某些第三表中。

1 个解决方案

#1


0  

Not entirely sure I understand the question, but I'll take a shot:

我不完全确定我理解这个问题,但我会接受一个镜头:

   Update PsychiciallyDiscernedThirdTable
      set m=b.m, an=c.an
     from value b
     join ans c
       on b.queid=c.queid1

#1


0  

Not entirely sure I understand the question, but I'll take a shot:

我不完全确定我理解这个问题,但我会接受一个镜头:

   Update PsychiciallyDiscernedThirdTable
      set m=b.m, an=c.an
     from value b
     join ans c
       on b.queid=c.queid1