i would strongly suggest using a datestamp for all of the actions in the
workflow - this is very useful to track the changes that are made during the
document's lifecycle and also would solve your problem (you could just
select the max date with id = 5)

-chris

-----Original Message-----
From: Imad Jradi [mailto:jradi@;hotmail.com]
Sent: Monday, October 21, 2002 11:43 AM
To: ActiveServerPages
Subject: RE: sql question


Thanks for the reply Chris,
but maybe I should've clarified it a bit more.
Table_B will also include other Ids from table_A.

TABLE B
--------
TABLE_B_ID - 3    TABLE_A_ID - 5     'Saved Document'
TABLE_B_ID - 8    TABLE_A_ID - 10    'sent to user 2'
TABLE_B_ID - 7    TABLE_A_ID - 5     'sent to user 2'
TABLE_B_ID - 5    TABLE_A_ID - 5     'Sent to User 1'
TABLE_B_ID - 18   TABLE_A_ID - 5     'User 2 approves document'
TABLE_B_ID - 23   TABLE_A_ID - 5     'sent to user 3'
TABLE_B_ID - 6    TABLE_A_ID - 5     'User 1 approves document'
TABLE_B_ID - 28   TABLE_A_ID - 10    'sent to user 3'
TABLE_B_ID - 49   TABLE_A_ID - 11    'sent to user 2'
TABLE_B_ID - 30   TABLE_A_ID - 17    'sent to user 7'



So I really can't select the highest id in table_B. But can I select the top
most ID in the resultset returned of the foreign key.
example: If I am looking for latest action performed for Id 29
Can I do the following:
SELECT TOP 1 * FROM Table_B
WHERE id = 29 ORDER BY Table_B_ID DESC

Thanks




>From: "Chris" <[EMAIL PROTECTED]>
>Reply-To: "ActiveServerPages" <[EMAIL PROTECTED]>
>To: "ActiveServerPages" <[EMAIL PROTECTED]>
>Subject: RE: sql question
>Date: Mon, 21 Oct 2002 10:41:15 -0400
>
>Imrad, we have to make some assumptions from your presentation.  Is it
>safe to presume it will always be the highest ID in the set of table B
>records that relates to the table A item?  That isn't always a safe
>assumption, but if it is here you can try this:
>
>SELECT TOP 1 * FROM Table_B
>WHERE ???? (whatever is your join or relation logic)
>ORDER BY Table_B_ID DESC
>
>This asked for the first record in a set that will have the highest ID
>in Table_B at the top.
>
>I'll repeat the caution though:  consider that the highest ID may not
>always be the last-created record.  Over time data gets cleaned, moved
>around, restored, and IDs can change.  It's rarely a Good Idea to assign
>meaning to them.  You might be safer using a timestamp field in Table_B
>that records the time it was created, and use the same logic as above to
>find the latest record that way.
>
>HTH
>
>
>-----Original Message-----
>From: Imad Jradi [mailto:jradi@;hotmail.com]
>Sent: Monday, October 21, 2002 10:34 AM
>To: ActiveServerPages
>Subject: sql question
>
>
>Hi Guys,
>I am having a problem constructing an sql query to return a specific
>record,
>so here's the situation:
>
>TABLE A
>--------
>TABLE_A_ID - 5
>
>TABLE B
>--------
>TABLE_B_ID - 3    TABLE_A_ID - 5     'Saved Document'
>TABLE_B_ID - 7    TABLE_A_ID - 5     'sent to user 2'
>TABLE_B_ID - 5    TABLE_A_ID - 5     'Sent to User 1'
>TABLE_B_ID - 18   TABLE_A_ID - 5     'User 2 approves document'
>TABLE_B_ID - 23   TABLE_A_ID - 5     'sent to user 3'
>TABLE_B_ID - 6    TABLE_A_ID - 5     'User 1 approves document'
>
>I want to be able to return the last record (the latest event in the
>workflow) of the workflow to the user that sent the document, which is
>TABLE_B_ID - 23 'Sent to user 3'. Now I don't know if this is simple,
>but
>for some reason I was having problem with it.
>Thanks for all the help.
>Imad
>
>
>
>
>
>
>_________________________________________________________________
>Internet access plans that fit your lifestyle -- join MSN.
>http://resourcecenter.msn.com/access/plans/default.asp
>
>
>---
>You are currently subscribed to activeserverpages as:
>[EMAIL PROTECTED] To unsubscribe send a blank email to
>%%email.unsub%%
>
>
>
>---
>You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
>To unsubscribe send a blank email to
>%%email.unsub%%


_________________________________________________________________
Broadband?�Dial-up? Get reliable MSN Internet Access.
http://resourcecenter.msn.com/access/plans/default.asp


---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to