SELECT `member_name.smf_members`, COUNT(`author.smf_links`)
FROM smf_members, smf_links
JOIN smf_links ON id_member.smf_members = author.smf_links;
GROUP BY `author.smf_links`
It says smf_links is not a unique table/alias. All I want to do is make it get a count of how many rows has the same author, and show the member name instead of the author (which is a number) and the count.
So instead of: 1 | 23
It would show: Bunny | 23
I can't figure this out and my brain has gone numb from googling. Can someone please help me out? :)
The error you're getting is because you're joining with the same table, smf_links
, twice. If that's what you really want to do, you need to give them aliases so you can distinguish them. But I suspect you did that by mistake.
Also, the syntax is tablename.column
, not column.table
. And you have to put the backticks around each part separately; if the .
is inside the backticks, it's treated as a literal character, not a delimiter.
SELECT `smf_members`.`member_name`, COUNT(*)
FROM smf_members
JOIN smf_links ON smf_members.id_member = smf_links.author
GROUP BY smf_links.author