update query creation

  • Can anyone help me to get this SELECT query turned into the proper MS SQL 7 UPDATE Query.  End result should SET ap_dept1113.scan_op = 'FirstName LastName

     

    select ap_dept1113.ck_num, ap_dept1113.scan_op, o_file.fileid, o_file.ownerid,

    o_file.mactype, o_file.ownerid

    from ap_dept1113, o_file

    where ap_dept1113.o_objid = o_file.fileid

    and o_file.ownerid = '1051'

    order by ck_num

     

    Thank you. 

  • First off where does firstname last name come from?

    I asume from your query it will be from the o_file table possibly but I don't see a column that says it would be the one.

    Then you basics will look like this.

    UPDATE

     ap_dept1113

    SET

     scan_op = o_file.whatevercolumngoeshere.

    FROM

     dbo.ap_dept1113 ap_dept1113

    INNER JOIN

     dbo.o_file o_file

    ON

     ap_dept1113.o_objid = o_file.fileid

    WHERE

     o_file.ownerid = '1051'

    ORDER BY

     ck_num

  • First name Last name comes from another table called o_user2 column name lname, column name fname.

  • The you just need to add that into the joins in the from section (test with a Select statement first and do just like I noted with that additionally.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply