use a subquery

update table set status = 'approved'
where sku = <cfqueryparam value="#url.sku#' and cfsqltype="cf_sql_varchar" />
and statuswhen = (
select max(statuswhen)
from status
where ... --include where clauses
)

On 6/12/06, Chad Gray <[EMAIL PROTECTED]> wrote:
> How would I write the SQL to update a record that has the most recent date?
>
> Say I want to change the status field to "Approved" where the date is the 
> most recent and SKU = 12345
>
> Will the Max function work in the Where section of the SQL or is there 
> another function to use to find the most recent date?
>
> UPDATE table
> SET STATUS = 'approved',
> WHERE SKU = #URL.SKU# AND MAX(StatusWhen)
>
>
> Thanks,
> Chad
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:243197
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to