I am trying to select all from stuff and count the total amount of items in morestuff where stuff id = morestuff id.
select *,
COUNT(morestuff.items) as total
from stuff,
morestuff
where stuff.id = '{$id}'
and morestuff.id = stuff.id
Obviously there is something wrong with my query, can anyone help?
Countrequire agroup by. Instead of trying to troubleshoot this via PHP, why not hit the DB directly and track down errors from there first? That might help you understand why this query doesn't work.SELECT COUNT(*) FROM my_tablefor example, is valid.countwith other non-aggregate fields.