开发者

SQL-query to find similar fields

In SQL, I have a table which have fields a_1,a_2,..., a_10. What kind of开发者_如何学编程 query says if I have rows s,t such that s.a_1=t.a_1 ,..., s.a_6=t.a_6 and for some j>6 we have s.a_i<>t.a_i?


Join table to itself on the condition you supplied. Like:

select
   a.ID 
from 
  table as a join table as b 
  on a.a_1 = b.a_1 and ... and a.a_j <> b.a_j
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜