Naveh Naveh - 6 months ago 40
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)


You can get it as follows:

SELECT Greatest(
          (SELECT Max(total_id) FROM posts),
          (SELECT Max(total_id) FROM threads)