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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subquery question? 1

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Ok, I have two tables -- one with 1000 records and the other with 100000...

the 1000 record table (tempTable) has two columns, rk and unit -- and the rk will match back to 1000 records in the other table, called heCustRK

So, I have values in the tempTable that I want to use to update the corresponding values in the heCustRK table...

Something like this:
update heCustRK set unit = tempTable.unit where heCustRK.rk = tempTable.rk

but of course, this doesn't work. Can anyone help me out with the syntax?

Thanks! :)
Paul Prewett
penny.gif
penny.gif
 
update heCustRK set cmiID =
(select unit from yanli.tempTable where yanli.tempTable.rk = heCustRK.rk)

:)
penny.gif
penny.gif
 

Here is the correct syntax for SQL Server.

UPDATE heCustRK SET unit = tempTable.unit
FROM heCustRK Inner Join tempTable
ON heCustRK.rk = tempTable.rk Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top