Compare the time of two tables and take all data larger than a certain time

Source: Internet
Author: User
A table A1 field is a Time field
b table B1 field is Time field

Two table association fields uid,a to user table, B to data table

The time data format is 0000-00-00 00:00:00

A UID time for the A1 field is a fixed time
B1 field is more than one variable time

Compare all data contents of B1 that UID is greater than A1 time, and remove all data larger than A1 if it is greater than B1.

How do I write this? Thanks, man.


Reply to discussion (solution)

has been done, more than one query SQL in contrast, but have not found a better way.

SELECT * from B LEFT join A on B.uid=a.uid where b.b1 > a.a1

SELECT * from B LEFT join A on B.uid=a.uid where b.b1 > a.a1

Later it is changed to this, but query the UID of the next level of data, can only be queried once, and then contrast. Thank you for it!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.