Query update table

C

Carlos

Hello, I have 2 tables and try update T1
T1: T2:
DD as Date Emp as Byte
Emp as Byte DD_I as date
Pos as Long DD_F as date
new_Pos as Long

E.g
T1
|-------DD--- |-Emp-|-Pos-|
| 2001-01-01 | 10 | 1 |
| 2001-01-02 | 10 | 1 |
| 2001-01-03 | 10 | 1 |
| 2001-01-04 | 10 | 1 |
| 2001-01-05 | 10 | 1 |
| 2001-01-06 | 10 | 1 |

T2
|-Emp- |-----DD_I--- |-------DD----|-new_Pos-|
| 10 | 2001-01-02 | 2001-01-03 | 3 |
| 10 | 2001-01-04 | 2001-01-05 | 5 |


new T1
|-------DD--- |-Emp-|-Pos-|
| 2001-01-01 | 10 | 1 |
| 2001-01-02 | 10 | 3 |
| 2001-01-03 | 10 | 3 |
| 2001-01-04 | 10 | 4 |
| 2001-01-05 | 10 | 5 |
| 2001-01-06 | 10 | 1 |

it is possible

Thanks

carman
 
V

Van T. Dinh

Try something like:

UPDATE T1 INNER JOIN T2
ON T1.Emp = T2.Emp
SET T1.Pos = T2.new_Pos
WHERE T1.DD
Between T2.DD_I And T2.DD_F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top