[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

T-SQL UPDATE QUERY - update table from another table based upon relationshp?

Posted on 2007-10-01
1
Medium Priority
?
13,440 Views
Last Modified: 2012-06-22
I'm storing affiliate records in a table ('affiliaterecords') on Microsoft SQL Server 2005, and each record generates a unique INT ID number that is used as the primary key.  Also a field named 'email'

I have another table called 'logins', which stores a login name, password, and related account ID's.

I want to run an UPDATE query that pulls (based upon a reltaionship with the e-mail address field) the affiliaterecord ID field and inserts it into the 'logins' table's column named 'affiliateid' based upon a match on the email address which is in each table....

I hope this makes sense!  Thanks
0
Comment
Question by:adworldmedia
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19994335
UPDATE logins
 SET affiliateid = ar.ID
FROM logins l
JOIN affiliaterecords ar
  ON ar.email = l.email
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question