Naveh Naveh - 1 year ago 88
MySQL Question

How to get max value of a column from two tables

I have one table named 'posts' and one table named 'threads'. Both have the column called 'total_id' which is an integer.
Now, how to get from those two tables the 1 highest value (max) in the 'total_id' column? (MySQL)

Answer Source

You can get it as follows:

SELECT Greatest(
          (SELECT Max(total_id) FROM posts),
          (SELECT Max(total_id) FROM threads)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download