S
Stian Berg
Hello
I have two tables, one for users and one for messages that the users have
written. I want to find the user who has written the most messages.
The tables:
User { *UserID, UserName, ... }
Message { *MessageID, UserID, MessageDate, Message, ... }
Primary keys is marked with *, and Message.UserID is of course the
foreign key from User.
The statement below will find the number of messages that the most active
user has written, but not which user this is. How can I do this?
SELECT MAX(AntMeldinger)
FROM ( SELECT COUNT(*) AS AntMeldinger
FROM User AS U, Message AS M
WHERE U.UserID =M.UserID
GROUP BY U.UserID
);
Thanks for your help.
I have two tables, one for users and one for messages that the users have
written. I want to find the user who has written the most messages.
The tables:
User { *UserID, UserName, ... }
Message { *MessageID, UserID, MessageDate, Message, ... }
Primary keys is marked with *, and Message.UserID is of course the
foreign key from User.
The statement below will find the number of messages that the most active
user has written, but not which user this is. How can I do this?
SELECT MAX(AntMeldinger)
FROM ( SELECT COUNT(*) AS AntMeldinger
FROM User AS U, Message AS M
WHERE U.UserID =M.UserID
GROUP BY U.UserID
);
Thanks for your help.