Kay,

> <cfquery name="get_messages" datasource="#application.dsn#">
>   select messages.text, messages.edit_date, users.name
>   from   messages, users
>   where  users.id = messages.sender
> </cfquery>
> 
> which is fine. However, if messages.edit_date is not null, I want to
> get another users.name that corresponds the id number stored in
> messages.edit_user, and display that in the middle of the same <cfoutput>
> block. I'm not sure how to differentiate the two users.name values, and
> how to keep them both with the right record. Can it be done in one query?
> Basically I'm trying to display a forum post, along with the username who
> posted it, and the username who last edited if it has been edited at all.

You can't do it in one query. There is a function called ISNULL() that
lets you substitute a given value for any nulls that come up, but you're
trying to do something a bit more complicated than that.

I suggest you write a stored procedure. That'll let you do the
IF-THEN-ELSE logic that you need & it'll be nice and fast.

Nick


**********************************************************************
Information in this email is confidential and may be privileged. 
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system. 
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone. 
Thank you for your co-operation.
**********************************************************************
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to