database - Access 2013, want to make sure my SQL is doing what I think it is -


my understanding following sql is:

(1) taking data tbl1 , updating tbl2

(2) both adding new records , updating old ones.

(3) overwriting existing data in tbl2

(4) not overwriting data in tbl2 blank cells

am off mark on 1 , if how?

update tbl1 inner join tbl2  on tbl1.thing0 = tbl2.thing0  set tbl2.[thing1] = tbl1.[thing1], tbl2.[thing2] = tbl1.[thing2], tbl2.[thing3] = tbl1.[thing3]; 

edit1

so satisfy conditions 2 , 4 , keep easy on users:

(2) use append query add new rows of data, update change existing rows.

(4) update query, how can prevent overwriting data in existing rows blank cells?

i have users on-site updating table in real time , worry remote users updating table once have connection overwrite on-site users data bunch of blank cells.

will satisfy condition 4?

update tbl1 inner join tbl2  on tbl1.thing0 = tbl2.thing0  set tbl2.[thing1] = tbl1.[thing1], tbl2.[thing2] = tbl1.[thing2], tbl2.[thing3] = tbl1.[thing3] not null: 

(5) attach macro command button users can run both queries @ same time.

  1. yes
  2. no - update doesn't add records; query updates records in tbl2, corresponding record(s) in tbl1 can found
  3. yes
  4. no - if corresponding row/record in tbl1 has empty/blank fields, these written tbl2 anyway

after op edits, re #4:

you can use iif() on set line, next (maybe should add trim() or check null values or similar):

set tbl2.[thing1] = iif(tbl1.[thing1] = '', tbl2.[thing1], tbl1.[thing1]) 

iif() ms access function; in proper sql have use case statement.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -