mysql> select * from on_connected;
+----+-----------+-------------+---------------------------+---------------------+
| id | extension | destination | call_id | created_at |
+----+-----------+-------------+---------------------------+---------------------+
| 11 | 1111111 | 01155555551 | 521243ad953e-965inwuz1gku | 2013-08-19 17:11:53 |
+----+-----------+-------------+---------------------------+---------------------+
mysql> select * from on_disconnected;
+----+-----------+-------------+---------------------------+---------------------+
| id | extension | destination | call_id | created_at |
+----+-----------+-------------+---------------------------+---------------------+
| 1 | 1111111 | 01155555551 | 521243ad953e-965inwuz1gku | 2013-08-19 17:11:57 |
+----+-----------+-------------+---------------------------+---------------------+
1 row in set (0.00 sec)
两者之间有4秒的时间差。我想使用某种类型的查询来计算差异。我知道 TIMEFIFF() 并加入,但此时缺乏形成查询的技能。
到目前为止,这是我的尝试:
SELECT TIMEDIFF(to_seconds(od.created_at), to_seconds(oc.created_at))
FROM on_connected oc
JOIN on_disconnected od
ON oc.call_id=od.call_id
WHERE call_id='521243ad953e-965inwuz1gku';
mysql报告:
ERROR 1052 (23000): Column 'call_id' in where clause is ambiguous