SELECT person.id,
person.name,
COUNT(DISTINCT fruit.apple) AS "Red Apple",
fruit.*
FROM (SELECT *
FROM tree
ORDER BY color DESC) AS fruit
INNER JOIN person
ON fruit.id = person.id
WHERE person.name = 'John Smith'
Now, that code is working before I put in the COUNT(DISTINCT fruit.apple) AS "Apple". what is wrong with that?
Thanks in advance
ORDER BY color DESCin the derived table definition? AlsoINNER JOIN people ON fruit.id = person.iddefinitely won't work. The table name changes midway through.mysql_fetch_assoc(): supplied argument is not a valid MySQL result resourcecoloractuallydatetype column, so I have to sort it descending, and.. those answers below are true :D thanks guys!