我與查詢拉動3個表中的唯一值進行爭吵。這是更好地完成在2個單獨的查詢?mysql查詢,從3個表中進行選擇
查詢是:
count as returned (
all leadID from lds where status = "ok"
AND leadID is also in rlds with recID="999"
AND rdate > (03-20-2012)
+
(all distinct leadID from plds where recID="999"
AND change != NULL
AND pdate > (03-20-2012))
工作查詢的結果應該是 「2」:leadID 1和leadID 4
表LDS:
leadID |狀態
1 |好吧
2 |不好
3 |好吧
表plds:
leadID | recID |改變| pdate
4 | 999 | ch1 | 03-27-2012
4 | 999 | ch2 | 03-27-2012
5 | 888 | NULL | 03-27-2012
表格地址:
leadID | recID2 | rdate
1 | 999 | 03-27-2012
6 | 999 | 03-27-2012
謝謝!
優秀的,這個作品 - 謝謝! – user1291842 2012-03-29 23:34:32