Table ="term_count" Each row has 2 fields = "term" and "count" There are hundreds of rows, I only need the four with the "term" field equalling 503,507,623, and 634. The output should be the four "count" fields added together. I just want to display the total number, would this be better to do with PHP script or a MySQl statement, and how?
You need to use both PHP and MySQL. MySQL retreives the data from the database, PHP allows you to display it. Here is the SQL for the query to get that information: SELECT SUM(term_count.count) AS total FROM term_count WHERE term=503 OR term=507 OR term=623 or term=634;
I would probably go with something like: SELECT SUM(`count`) AS total FROM term_count WHERE term IN (503,507,623,634); Make sure you reference the count column using backticks `count`. COUNT() is a mysql function so you need the backticks to tell the database that you want the column and not the function.