Ask Paula!

...bringing you notes from the field...
posts - 117 , comments - 87 , trackbacks - 0

My Links

News

Copyright © 2008-2014 Paula DiTallo

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

.NET Development

Enterprise Integration

Entertainment - Games

Java Development

Mobile/PDA Development

Professional Affiliations

SQL Update Statement - using SubSelect


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
  )

Print | posted on Friday, May 29, 2009 10:34 AM | Filed Under [ SQL ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 

Powered by: