在一个表中比较查询结果并报告“ True”或“ False”

时间:2018-07-21 11:36:16

标签: mysql

我在mysql中有一个表,其中包含一些NE的大量数据。我想创建一个比较列值和“ True”或“ False”的报告。

下表是我的查询的一部分,我想获取T1和T2的所有数据并比较值coulmn,它是相同的,在新列中输入“ True”,否则将“ False”放置。

+------------+----------+-----------------+-------------------------------------------------------------+--------------+
| date       | rnc      | mo              | parameterid                                                 | Value        |
+------------+----------+-----------------+-------------------------------------------------------------+--------------+
| 2018-07-11 | T1       | INTERRATHOCOV   | INTERRATCSTHD2DECN0                                         | -17          |
| 2018-07-11 | T2       | INTERRATHOCOV   | INTERRATCSTHD2FECN0                                         | -14          |
| 2018-07-11 | T1       | UMULTIRABHOCOV  | CSPSMRABTHD2DECN0                                           | -15          |
| 2018-07-11 | T2       | UMULTIRABHOCOV  | CSPSMRABTHD2FECN0                                           | -12          |
| 2018-07-17 | T1       | CORRMPARA       | PERFENHANCESWITCH9_PERFENH_NON_CS_RAB_RELOC_OPT_SW          | 0            |
| 2018-07-17 | T2       | CORRMPARA       | PERFENHANCESWITCH9_PERFENH_NON_PS_RAB_RELOC_OPT_SW          | 0            |
| 2018-07-19 | T4       | CORRMPARA       | PERFENHANCESWITCH9_PERFENH_NON_CS_RAB_RELOC_OPT_SW          | 0            |
| 2018-07-19 | T4       | CORRMPARA       | PERFENHANCESWITCH9_PERFENH_NON_PS_RAB_RELOC_OPT_SW          | 0            |
+------------+----------+-----------------+-------------------------------------------------------------+--------------+

1 个答案:

答案 0 :(得分:1)

您是否尝试过将表与自身连接?

import UIKit

class IP4 {
    var ipA: Int?
    var ipB: Int?
    var ipC: Int?
    var ipD: Int?

    func fullIP() -> Int {
        var parts: [Int] = []

        if let ipA = self.ipA {
            parts += [ipA]
        }

        if let ipB = self.ipB {
            parts += [ipB]
        }

        if let ipC = self.ipC {
            parts += [ipC]
        }

        if let ipD = self.ipD {
            parts += [ipD]
        }
        return parts.joined(separator: ".")
    }
}

let ipaddress = IP4()
ipaddress.ipA = 223
ipaddress.ipB = 9
ipaddress.ipC = 50
ipaddress.ipD = 60