Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using aliases on delete/update statement

Status
Not open for further replies.

chris123321

IS-IT--Management
Mar 13, 2007
139
US
How would I shorten this query by using aliases?
Code:
        DELETE tblEventContacts
        FROM tblEventContacts 
          INNER JOIN @Contact C
            ON tblEventContacts.ContactID_F = C.ContactID
        WHERE tblEventContacts.EventID_F = @EventID AND C.Removed = 1
Code:
        UPDATE tblEventContacts 
        SET tblEventContacts.Accepted = C.Accepted, 
            tblEventContacts.Declined = C.Declined, 
            tblEventContacts.DidNotRespond = C.DidNotRespond,
            tblEventContacts.Attended = C.Attended, 
            tblEventContacts.Comment = C.Comment
        FROM tblEventContacts 
        INNER JOIN @Contact C
          ON tblEventContacts.ContactID_F = C.ContactID
        WHERE C.Modified = 1 AND tblEventContacts.EventID_F = @EventID

Thanks.
 
The same way you used an alias for @contact

"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top