zoukankan      html  css  js  c++  java
  • how to determint wether two column equals

    question:

    How to determint  wether two column equals?

    Answer:

      Table one:RecordId = 1,CommonId = 5,Approved = 1.

           RecordId = 2,CommonId = 5 Approved = 0.  

    Table two:RecordId = 4,CommonId = 9,Approved = 1.

      case one:if you are compare  in the one table.

      you can use the following code

    select commonId,
           (case when max(Approved) = min(Approved) then 1 else 0 end) as IsEqual
    from MyTable A
    group by commonId;

    case two:if you are compare in the two tables.

    you can use the following code.

    SELECT 
        CASE 
            WHEN (A.Approved = B.Approved) THEN 1
            ELSE 0
        END
    FROM MyTable A,
    MyTable B
    WHERE A.commonId = B.commonId;     
    Note:you need modify condition A.Approved = B.Approved only ,in compare two tables different column.

     

  • 相关阅读:
    Java面向对象设计——购物车·
    查找

    栈和队列
    指针
    数组
    第四次博客——函数
    第三次博客作业
    第二次博客作业
    Java购物车大作业01
  • 原文地址:https://www.cnblogs.com/yjhlsbnf/p/7769093.html
Copyright © 2011-2022 走看看