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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -