Geeks With Blogs

News Copyright © 2008-2013 Paula DiTallo
Ask Paula! ...bringing you notes from the field...

This is a simple, but helpful example of changing a boolean or bit flag in a table to 'True' when the condition in the subSelect is met.  In this context, the SQL statement finds all the cases where a sales agent's email exists in the Metro_SalesForce table and exists in the related table Metro_SalesForceMult. The Metro_SalesForceMult table contains the USA state assignments only for sales agents representing more than a single state.



UPDATE Metro_SalesForce
 SET multipleStates = 'True'
WHERE Metro_SalesForce.email in
  (
     Select x.email
       From Metro_SalesForce x, Metro_SalesForceMult y
        Where x.email = y.email
  )
Posted on Friday, May 29, 2009 10:34 AM SQL | Back to top


Comments on this post: SQL Update Statement - using SubSelect

No comments posted yet.
Your comment:
 (will show your gravatar)
 


Copyright © Paula DiTallo | Powered by: GeeksWithBlogs.net | Join free