HI there Christoph,
Just implemets an Insert Trigger in Table 2 that will update the record in
table 1.
Tiago Costa
[quoted text, click to view] "Christoph" <jcboget.no_spam@spam_trap.yahoo.com> wrote in message
news:O2Fr5Yr1GHA.3908@TK2MSFTNGP05.phx.gbl...
>I have 2 tables. Simplified down to relevant fields.
>
> Table 1
>
> id
> referenceName
> currentStatus
>
> Table 2
>
> id
> table1Id
> transactionStatus
>
> There is a many to 1 relationship between table 2 and table 1. Table 1
> holds 1 reference record and Table 2 can have multiple records, each
> having the status for a particular transaction. I'm trying to update the
> Table1.currentStatus field to have the value of the status of the last
> associated record in Table 2. For example, if Table 2 had the following
> records:
>
> 1, 55, fail
> 2, 55, pass
> 3, 55, fail
> 4, 55, fail
>
> the currentStatus for id 55 in table 1 would be 'fail'. If Table 2 had
> the following records:
>
> 19, 13, pass
> 20, 13, fail
> 21, 13, fail
> 22, 13, pass
>
> the currentStatus for id 13 in table 1 would be 'pass'. Here is the query
> that I've come up with but it's not working as expected.
>
> UPDATE Table1
> SET Table1.currentStatus =
> Table2.transactionStatus FROM
> Table2 INNER JOIN Table1 ON
> Table1.id = Table2.Table1Id
>
> How can I update table 1 how I need to?
>
> thnx,
> Christoph
>