
January 4th, 2005, 07:02 AM
|
|
Contributing User
|
|
Join Date: Oct 2004
Posts: 39
Time spent in forums: 5 h 7 m 7 sec
Reputation Power: 5
|
|
SQL in MS Access Database
Hey all.. I was wondering if anyone would be able to help because I am really stuck with this..
Basically in an Access Database holding messages of online chat conversations I need to run a query to find out which is the longest message and which is the shortest message sent. In order to this the number of characters need to be counted and then the max and min selected however I'm having problems with the data type of the message
Based on the LEN function I first tried :
SELECT User.User, Message.Message
FROM Message INNERJOIN [User] ON Message.[Message ID] = User.[Message ID]
ORDER BY LEN(Message) DESC;
This selected the user and message fields and ordered them based on the length of the message.
In the original Message Table the message field is set to Memo as there are quite long messages the above SQL did incorporate the full messages and ordered them in the correct manner...
HOWEVER.. I need to be able to count the number of characters per message and retrieve the longest message and then retrieve the shortest message.
I tried..
SELECT Message.Message, LEN(Message) AS [No of characters]
FROM Message INNERJOIN [User] ON Message.[Message ID] = User.[Message ID]GROUP BY Message.Message;
This counted the number of characters for each message but it did not incorporate the full messages, the maximum number of characters for the longer messages came up as 255 whereas I know that they are longer than that.. and it only displayed those 255 characters and cut off the rest of the message.
Ultimately I need to select the 'User' from the user table, 'Message' from the message table, Count the number of characters per message and then display the highest but the function needs to be aware of the messages that have characters more than 255 hence the Memo data type setting in the Message Table..
... any ideas/developments on the above??
I have been trying a few different things but getting no-where at the moment..
Any help would be greatly appreciated.
|