我有3个表let reachabilityManager = NetworkReachabilityManager()
reachabilityManager.listener = { status in
switch status {
case .notReachable:
print("The network is not reachable")
self.onInternetDisconnection()
case .unknown :
print("It is unknown whether the network is reachable")
self.onInternetDisconnection() // not sure what to do for this case
case .reachable(.ethernetOrWiFi):
print("The network is reachable over the WiFi connection")
self.onInternetConnection()
case .reachable(.wwan):
print("The network is reachable over the WWAN connection")
self.onInternetConnection()
}
}
,scan_1
,scan_2
。这是SQL模式的结构:
scan_3
我想将scan_1: scan_2: scan_3:
P_no work P_no work P_no work
1 YES 1 YES 1 NO
2 NO 2 NO 2 NO
3 YES 3 YES 3 NO
计算在P_no
。但是,如果在work ='YES'
的{{1}}的2个位置发生了,则P_no = 1
和scan_1
中的“是”,则必须计为1。
我的查询是:
scan_2
答案 0 :(得分:1)
据我所知,这可能对你有用。使用union来消除重复。
select count(*) AS `ab1` FROM
(
select `P_no`,`work` from `scan_1` s1 where `work`= 'YES'
union
select `P_no`,`work` from `scan_2` s2 where `work`= 'YES'
union
select `P_no`,`work` from `scan_3` s3 where `work`= 'YES'
) as final
答案 1 :(得分:1)
尝试:
SELECT COUNT(*) AS total_count
FROM
(
SELECT P_no, work FROM scan_1 WHERE work = 'YES'
UNION
SELECT P_no, work FROM scan_2 WHERE work = 'YES'
UNION
SELECT P_no, work FROM scan_3 WHERE work = 'YES'
) AS total
答案 2 :(得分:1)
您可以使用 UNION 获得所需的结果,如下所示:
const functions = require('firebase-functions');
var iapReceiptValidator = require('iap-receipt-validator');
const password = 'xxxx'; // Shared Secret from iTunes connect
const production = false; // use sandbox or production url for validation
var validateReceipt = iapReceiptValidator(password, production);
exports.validate = functions.https.onRequest((request, response) => {
try {
const validationData = await validateReceipt(request.body.receiptData);
response.send(JSON.stringify(validationData));
} catch(err) {
console.log(err.valid, err.error, err.message)
}
});
注意使用 UNION合并的三个查询。它合并结果并从结果中排除重复记录。
答案 3 :(得分:0)
试试这个,
SELECT COUNT(DISTINCT P_No) AS ab1
FROM (
SELECT P_no, work FROM scan_1
UNION
SELECT P_no, work FROM scan_2
UNION
SELECT P_no, work FROM scan_3
) T
WHERE T.Work='YES'
希望这会对你有所帮助。