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

SQL to update a column using another table

Status
Not open for further replies.

James4099

MIS
Mar 16, 2000
2
0
0
US
I would like to know if you can update Table(A)
from Table(B). My Sql is:

UPDATE DDT4ENVR.CCR
SET USML_IND ='Y' WHERE USML_IND 'b'
(SELECT USML_IND FROM DDT4ENVR.THR WHERE USML_IND = 'Y')

Thanks.
 
UPDATE DDT4ENVR.CCR
SET USML_IND = (SELECT USML_IND FROM DDT4ENVR.THR WHERE USML_IND = 'Y')
 
BarkingFrog, your subquery will return one or more instances of 'Y' -- one for every row in the DDT4ENVR.THR which has USML_IND='Y' -- and if it returns more than one, then the UPDATE fails on a syntax error

that surely isn't right :)

james, what are you trying to do?

r937.com | rudy.ca
 
I'm trying to update Table DDT4ENVR.THR from Table DDT4ENVR.CCR. So if I have more then one to update I can 't used SQL to do it. I'm trying to select all (USML_IND that = 'Y' and update Table DDT4ENVE.CCR with the same data. I do appreciate all the help that you can give me on this problem. Jim.
 
jim, i understand you want to update one table from the other

what does "if I have more then one to update I can't used SQL to do it" mean?

do both tables have a field called USML_IND?

how do you want to match up the rows?

can you give a few rows of sample data from each table and show how the update should work?

r937.com | rudy.ca
 

hi,

How do i use sql to create table of values?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top