Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update table with left join
Message
From
17/10/2011 12:25:32
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Desktop
Miscellaneous
Thread ID:
01526632
Message ID:
01526642
Views:
31
>>>>is something like this possible? I get an error, but I thought it should have worked:
>>>>
>>>>UPDATE EmpItems 
>>>>    LEFT JOIN HistItems ON HistItems.eiKey = EmpItems.eiKey
>>>>    WHERE HistItems.DelFlag = 0 
>>>>    SET EmpItems.itOnPosted = 1, EmpItems.itBalAmt = HistItems.itBalNew + HistItems.itPostCalc
>>>>
>>>>Maybe I'm doing something wrong?
>>>
>>>The SET clause must be right after UPDATE.
>>>
>>>UPDATE EmpItems 
>>>SET itOnPosted = 1, 
>>>itBalAmt = HistItems.itBalNew + HistItems.itPostCalc
>>>
>>>FROM EmpItems
>>>INNER JOIN HistItems ON HistItems.eiKey = EmpItems.eiKey -- no need to use LEFT JOIN
>>>    WHERE HistItems.DelFlag = 0 
>>>
>>
>>I was so used to flip that around in VFP!
>
>Hmm, never tried flipping it around in VFP either. BTW, pay attention to other changes I made in your query.

Great, it's working good, and fast. Problem was that originally I had a scan doing the updates in Business objects and posting one by one, and that took too long, so I had to do a direct query to update all at once.
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform