1
idx info market po side odd unique_odd
10 927606 OU_OT 2.5 under 2.01 927606_OU_2.5_under
11 927606 OU_OT 2.5 under 2.02 927606_OU_2.5_under
12 927606 OU_OT 2.5 over 1.81 927606_OU_2.5_over
13 927776 OU_OT 3.5 under 1.67 927776_OU_3.5_under
14 927776 OU_OT 3.5 over 2.11 927776_OU_3.5_over
15 927776 OU_OT 3.5 over 2.31 927776_OU_3.5_over
odds_etc DATABASE在這裏。FASTest> mysql獲取最後的不同記錄返回所有列
我想輸出像這些。
11 927606 OU_OT 2.5 under 2.02 927606_OU_2.5_under
12 927606 OU_OT 2.5 over 1.81 927606_OU_2.5_over
13 927776 OU_OT 3.5 under 1.67 927776_OU_3.5_under
15 927776 OU_OT 3.5 over 2.31 927776_OU_3.5_over
這意味着不同的用於unique_odd和MAX(IDX) 它可能以下SQL,但它需要7秒。它太長了,我想要1〜2秒。
SELECT T1.* FROM odds_etc T1
INNER JOIN (SELECT unique_odd,MAX(idx) as maxidx FROM odds_etc GROUP BY unique_odd) groupT2
ON T1.unique_odd = groupT2.unique_odd AND T1.idx = groupT2.maxidx
WHERE info='$info'
它的工作原理,但幾乎1分鐘。 – user3734604 2014-11-03 15:03:39
$ sql =「SELECT * \t FROM odds_etc T1 where idx =(SELECT MAX(idx)from odds_etc T2 WHERE T1.unique_odd = T2.unique_odd)」;我也試過了,也需要1分鐘。 – user3734604 2014-11-03 15:13:48
@ user3734604。 。 。那是與兩個索引? – 2014-11-03 15:17:20