西西河

主题:【求助】一个MySQL query的问题 -- 阿国

共:💬6 🌺2 新:
全看分页树展 · 主题 跟帖
家园 可以做到

可以,做三个virtual table,你没给完整的table schema,所以只大致提一下用法

select a3.uid,TIMESTAMPDIFF(second,a1.timestamp,a2.timestamp)... from

(select abclog_id,timestamp, ... from table_one where log_type_id=81) a1,

(select abclog_id,timestamp, ... from table_one where log_type_id=82) a2,

(select abclog_id,uid,... from table_two where

...) a3

where a1.abclog_id=a2.abclog_id

and a1.abclog_id=a3.abclog_id

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河