In my database I have two tables and want to select highest 5 values from table but I only get first highest value cannot get more than one value.
Here is my SQL,
SELECT * FROM table1 WHERE id=(SELECT id, MAX(num1+num2) FROM table2 limit 5)
How can I get first top 5 highest values?
Thanks.
This should do it
SELECT id, num1 + num2 AS total FROM table1 ORDER BY num1 + num2 DESC LIMIT 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With