Results 1 to 5 of 5

Thread: Update table where criteria depends on other table column for Access 2000 [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Resolved Update table where criteria depends on other table column for Access 2000 [RESOLVED]

    i got 2 table..table1, table2(which is like the duplicate for table2 for specific reason in my company)

    table1 = col1 + qty
    table2 = date_now + col1 + qty

    every month table2's content is change according to what table1 has..but somehow (not sure why it happens) it only inserted date_now and col1..

    so now i need to update table2.qty where the table2.col1 = table1.col1..
    is it possible? can't figure it out what the syntax are

    thx
    Last edited by erickwidya; Feb 8th, 2006 at 09:05 PM. Reason: forgot to mention the Database

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Update table where criteria depends on other table column

    Are you looking for something like...?

    VB Code:
    1. INSERT INTO Table2... SELECT * FROM Table1
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Update table where criteria depends on other table column

    thx dee-u but that's not what i'm mean

    ex: in t1
    col1 - col2
    a - 1
    b - 2
    c - 3

    in t2
    col1 - col2
    a - 0
    b - 0

    the update need to make t2 something like this
    col1 - col2
    a - 1
    b - 2

    since c not found in t2 then leave it alone

    hope it makes sense

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  4. #4
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Update table where criteria depends on other table column for Access 2000

    erickwidya:

    Maybe I am not understanding you correctly, but isn't it just a matter of doing a SQL UPDATE?

    Looks like you almost wrote it in your posting:

    update table2.qty where the table2.col1 = table1.col1
    Is very close.

    The syntax for a SQL UPDATE is:
    UPDATE table_name
    Set column = value
    WHERE condition

    So, you need something like:

    UPDATE table2
    SET qty = qty
    WHERE table2.col1 = table1.col1

    I may be a little bit off, but I think this should get you pretty close.

    The SET statment might need to be:
    SET qty = table1.qty

    Good Luck

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Update table where criteria depends on other table column for Access 2000

    UPDATE table2
    SET qty = qty
    WHERE table2.col1 = table1.col1
    -> aaa..u cheat, u use my logic , why MS doesn't developt this kind of magic

    just try it, and it work..never thought about it until i saw urs
    Code:
    UPDATE table2 INNER JOIN table1 ON table2.col1 = table1.col1 
    SET table2.qty = table1.qty
    -> i don't know it can use JOIN huaa...

    thx again for the insight AIS4U
    Last edited by erickwidya; Feb 8th, 2006 at 09:08 PM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width