Update statement using SQL Compact Query Analyzer

Answered Update statement using SQL Compact Query Analyzer

  • Tuesday, December 18, 2012 8:36 PM
     
     

    Hi,

    I have two Tables, TblCust and TblTemp as below:

    TblCust CustCode CustName
      T01  
    TblTemp TempCode TempName
      T01 Andy Skinner

    Please help me to write an Update statement to update the CustName from TblTemp.

    I am using SQL Compact Query Analyzer version 0.9.1.39515 by Christian Resma Helle 2011.  The database file type is SDF.

    Regards,

    Toyogo

All Replies

  • Wednesday, December 19, 2012 7:22 PM
     
     Answered Has Code

    Hello Toyogo,

    I haven't tested it, especially not with that tool, but may one of the two solutions will work:

    -- Solution 1 with JOIN
    UPDATE C
    SET CustName = T.TempName
    FROM TblCust AS C
         INNER JOIN
         TblTemp AS T
             ON C.CustCode = T.TempCode
    
    -- Solution 2 with sub select
    UPDATE TblCust
    SET CustName = (SELECT TempName
                    FROM tblTemp
                    WHERE TempCode = CustCode)


    Olaf Helper

    Blog Xing