Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating where the date is the oldest 1

Status
Not open for further replies.

copeZero

Programmer
Aug 31, 2007
46
CA
Hi i'm using smallDateTime for column InsertDate,

In the table i have 4 MID rows, each with a CredStr & MID

I'm trying to update the record where the InsertDate is the oldest date, this is what i have, any thoughts on this one?

Thanks.


Code:
UPDATE [_Credent] SET CredtStr=@CredStr WHERE
(Selete Min(InsertDate) from [_Credent]) AND MID=@MID
 
I think you mean something like this?

Code:
WHERE
InsertDate = (Select Min(InsertDate) from [_Credent] where MID = @MID) 
AND MID=@MID

You need to make sure you include the MID = @MID in your subquery, or else you may not have a match because your earliest InsertDate could be different from the earliest where MID = @MID (and therefore 0 rows could be updated). Does this make sense?

Hope it helps,


Alex

[small]----signature below----[/small]
With all due respect, Don Bot, I don't think we should rely on an accident happening. Let's kill him ourselves.

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top