Most active user

Codes here !

Moderators: macek, egami, gesf

zeep25
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 14, 2003 7:23 pm

Most active user

Postby zeep25 » Wed Jun 25, 2003 3:11 pm

ok i have a table which has entries of posts about music artists ...

the table looks something like :

ID | ARTIST | TITLE | AUTHOR | ALBUM | HITS | POST

well the author column has the name of the person who posted that

well i want to do is display who has posted the most .. like Craziest Poster : blablabla ....

i tried :

Code: Select all

SELECT author, COUNT(*) AS top FROM table GROUP BY author ORDER BY top DESC


gives me an error .. any help would be apreciated :)

Flood
New php-forum User
New php-forum User
Posts: 23
Joined: Tue Jun 24, 2003 4:49 am

Postby Flood » Wed Jun 25, 2003 3:18 pm

Hi!

Sorry, I will not fully answer your question (at least not yet).

First of all, if I were you and since it seems that you are at the beginning of your project, I would re-design my database: for instance, there might be several titles for a same artist and the way you have designed it will lead to redundancy... I would therefore create a table artist, then instead of putting the artist name, I would put an artist identifier in the table you described in your post. And it would allow to add also some extra information about each band...
Perhaps the same with author and album by the way.

Then, to help you, I guess that we need to know the error you got.

/Flood

zeep25
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 14, 2003 7:23 pm

Postby zeep25 » Wed Jun 25, 2003 3:26 pm

good suggestion but this is a little temporary thing i am doing for a class project ..

i get this error :

Error in query: SELECT author, COUNT(*) AS top FROM table GROUP BY author ORDER BY top DESC; . You have an error in your SQL syntax near '; ' at line 1

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Wed Jun 25, 2003 5:38 pm

Your syntax is correct. Check to make sure your spelling is correct and that the tables and fields actually exist.

zeep25
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 14, 2003 7:23 pm

Postby zeep25 » Thu Jun 26, 2003 2:12 pm

stupid me .. i put the ';' before the " ... so that was messin u pma query .. thnx ppl :)


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests