php - SQL query, choosing the nearest DateTime data from two column in different tables -
i show nearest datetime data sql query data across 2 table. have code socialdatabase.socialstart > now() limit 1
pick recent data 1 table , know trainingdatabase.socialstart > now() limit 1
same thing other table.
so how go merging these nearest data combined list of socialdatabase , trainingdatabase tables
thanks
you can use union syntax:
(select socialstart, data socialdatabase socialdatabase.socialstart > now() limit 1) union (select socialstart, data trainingdatabase trainingdatabase.socialstart > now() limit 1) order 1 desc limit 1
Comments
Post a Comment