1
您好我有以下兩個表:MySQL查詢返回空結果集
設備表:
deviceID accountID InstallTime fName lName
1 2 NULL Dave O'Riordan
2 2 NULL Kathrine Hutter
3 2 NULL Guy Swider
a2_deal表:
deviceID companyID contactID stage event state serverTime clientTime monetary
1 1 1 -1 CALL OUT 1349445600 1349445600 4600
1 14 12 -1 CALL OUT 1349449200 1349449200 5400
2 16 19 -1 CALL OUT 1349445600 1349445600 4456
2 21 20 -1 CALL OUT 1349449200 1349449200 4000
3 17 22 -1 CALL OUT 1349447160 1349447160 12000
1 1 1 1 CALL OUT 1349082060 1349082060 NULL
1 14 12 1 CHECK IN 1349083380 1349083380 NULL
1 1 1 1 CHECK IN 1349082660 1349082660 NULL
1 14 12 1 CHECK OUT 1349085382 1349085382 NULL
1 1 1 1 CHECK OUT 1349082700 1349082700 NULL
我做了一個查詢作爲如下:
SELECT deal.deviceID, devices.fName, devices.lName, SUM(event) AS visits
FROM `a2_deal` AS deal
LEFT JOIN `devices` AS devices ON deal.deviceID = devices.deviceID
WHERE `event` LIKE 'CHECK'
AND `serverTime` >= 1349082060
AND `serverTime` <= 1349190000
GROUP BY deal.deviceID
ORDER BY visits
它工作得很好,給我造成.... 但是當我試圖以檢索從列階段在a2_deal表基於條件的給我任何結果(結果爲空)的數據...
SELECT deal.deviceID, devices.fName, devices.lName, SUM(stage) AS closes
FROM `a2_deal` AS deal
LEFT JOIN `devices` AS devices ON deal.deviceID = devices.deviceID
WHERE `stage` = -1
AND `serverTime` >= 1349082060
AND `serverTime` <= 1349190000
GROUP BY deal.deviceID
ORDER BY closes
任何建議,我在做什麼錯了...謝謝你
而不是使用兩個'AND's,切換到'BETWEEN' – hjpotter92