I have this request -
SELECT interest_desc, categoryID, MAX(num_in_cat) AS num_in_cat FROM ( SELECT interest_desc, categoryID, COUNT(categoryID) AS num_in_cat FROM interests GROUP BY interest_desc, categoryID ) subsel GROUP BY interest_desc, categoryID
I want to change it to eventually display the category name from a separate table named categories
. All I can display is categoryID
from interests
with this sql
Both table structures
Category table structure
I know some kind of connection is required, but I looked at the examples and struggled to get the exact syntax.
I have this in a php script - this is an echo statement - this is
"{$result['interest_desc']} was the most popular in category {$result['categoryID']} with {$result['num_in_cat']} occurrences\n";
and its conclusion -
"Adidas was the most popular in category 5 with 1 occurrences"
I want the output to be "Adidas was the most popular in Sport with 1 entry"
However, my sql query does not contain category_desc
.
source share