Update one table with another table record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murtazadoc
    New Member
    • Aug 2010
    • 5

    Update one table with another table record

    Hy...

    am having a query regarding updating a table A records from table b on a button click...

    have created connection sting and commandtext to exexute d query
    am tryn ds query bt it seems to throw some syntax error

    Code:
    cmd.CommandText = 
    "UPDATE stockno_table SET(product_id,Sold,Rec_No)
    =(SELECT product_id,Sold,Rec_No from stockno_temp_copy 
    where stockno_temp_copy.stock_no=stockno_table.stock_no) where(exists)(stockno_table.stock_no=stockno_temp_copy.stock_no)"
    basically the fields are same bt the stockno_temp_co py is a temporary table which i want to empty always while it updates all the table records to stockno_table.. .

    all the records except the Sold which is YES/NO field changes...
    NB: Access DB is used

    Please advice me on this...
    Thanx,
    Mdoc
  • murtazadoc
    New Member
    • Aug 2010
    • 5

    #2
    anyways I found the solution for the above...
    Code:
    UPDATE stockno_table inner join stockno_temp_copy on stockno_table.stock_no = stockno_temp_copy.stock_no set stockno_table.Sold = stockno_temp_copy.Sold
    this is for those having similar probs...

    Mdoc

    Comment

    Working...