Help Forming An SQL Query That Selects The Max Difference Of Two Fields
- by Frank
I'm trying to select a record with the most effective votes. Each record has an id, the number of upvotes (int) and the number of downvotes (int) in a MySQL database.
I know basic update, select, insert queries but I'm unsure of how to form a query that looks something like:
SELECT * FROM topics WHERE MAX(topic.upvotes - topic.downvotes).
Please excuse my made up SQL. The tutorials on SQL I find on the internet cover very basic stuff. Does anyone recommend a good book on this subject?