Hi,
I have two tables
Table Messages:
prim_Key Truck Message MessageTime Country City
1 ABC999 'some message' 21.7.2008 16:01 ? ?
2 ABC123 'another message' 21.7.2008 16:25 ? ?
Table Positions:
prim_key Truck MeasuredTime Country City
1 ABC999 21.7.2008 12:51 Germany Kiel
2 ABC999 21.7.2008 14:51 Germany Hamburg
3 ABC999 21.7.2008 19:20 Germany Berlin
4 ABC123 21.7.2008 16:20 France Paris
We have our trucks going around whole Europe. Several times a day we exchange short electronical messages between our Dispatching and each Truck. Moreover we have a GPS system which every 2nd minute writes each Truck's position to a table. Basically I want to write an insert trigger on the Message table which updates the Message table with the Country and City from the Positions table based on the record in the Positions table which have the closest MeasuredTime to MessageTime in the Messages table.
In this case record nr 1 in the Messages table should be updated with Germany as Country and Hamburg as City.
Thanks in advance for your help.
-Sri.
question 2: why save the country+city, wouldn't it be more efficient to just store the positions.prim_key value in a single column of messages table?
question 3: the messages get inserted "later" than the actual "MessageTime"?