Hi,
The issue: I need to pull 1 random record form a table to send a message via email to a recipient.
Client can select times and message types.
Once a message has been sent it is flagged and won't be sent again to the client (until all messages within a given category have been sent to the client and then the system reloads the list).
I don't want to sort by message id for several reasons. However, when I run the following query, the recipients receive messages in Alphabetical order.
<cfquery name="NAME" datasource="#clientdsn#" maxrows="1">
Select message,messageid...
From TABLE
Where Messagetypeid = '#checkemails.messagetype#' AND Not Exists
(Select 1 from clienttomessagesent
Where clienttomessagesent.messageid = messages.messageid and clienttomessagesent.clientid = '#checkemails.clientid#')
ORDER BY RAND()
</cfquery>
How do I simply pull a random message from the list?
Driving me nuts.
The issue: I need to pull 1 random record form a table to send a message via email to a recipient.
Client can select times and message types.
Once a message has been sent it is flagged and won't be sent again to the client (until all messages within a given category have been sent to the client and then the system reloads the list).
I don't want to sort by message id for several reasons. However, when I run the following query, the recipients receive messages in Alphabetical order.
<cfquery name="NAME" datasource="#clientdsn#" maxrows="1">
Select message,messageid...
From TABLE
Where Messagetypeid = '#checkemails.messagetype#' AND Not Exists
(Select 1 from clienttomessagesent
Where clienttomessagesent.messageid = messages.messageid and clienttomessagesent.clientid = '#checkemails.clientid#')
ORDER BY RAND()
</cfquery>
How do I simply pull a random message from the list?
Driving me nuts.