Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
2つの異なるテーブルから2つのフィールドを減算する必要があります。一方のフィールドは日時で、もう一方のフィールドはタイムスタンプです。
それを達成するための最良の方法は何ですか?
最初にUNIXタイムスタンプに変換しますか?
何かのようなもの:
select UNIX_TIMESTAMP(t1.col1) - UNIX_TIMESTAMP(t2.col2) from t1, t2 ...
TIMESTAMPDIFFはるかに用途の広い選択肢です。
TIMESTAMPDIFF
select timestampdiff(SECOND, t1.col1, t2.col2);
フィドルでそれを見る