主题:【求助】一个MySQL query的问题 -- 阿国
共:💬6 🌺2
select count(a1.abclog_id) from abclog_entries_20080301 a1 where a1.log_type_id=86 and a1.abclog_id in (select a2.abclog_id from abclog_entries_20080301 a2 where a2.log_type_id=89 and a2.abclog_id in (select a3.abclog_id from abclogs_20080301 a3 where a3.box_id=57 and a3.a_type_id=84 and a3.b_type_id=49));
+---------------------+
| count(a1.obslog_id) |
+---------------------+
| 40957 |
+---------------------+
1 row in set (26.51 sec)
因为如果有89就一定要有86, 但有89不一定有86. 当然, 我还要计算时间差, 希望不会慢很多.
- 相关回复 上下关系4
🙂可以做到 1 pdwolf 字415 2008-03-02 18:56:58
🙂可以用, 不过效率是个问题 阿国 字69 2008-03-02 20:47:46
🙂优化就要具体问题具体分析了 pdwolf 字119 2008-03-02 20:52:59
🙂想到一个方法, 快了N倍