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!

Easy Update Question

Status
Not open for further replies.

trk1616b

MIS
May 25, 2005
20
0
0
US
This should be an easy question, but I rarely mess with SQL.

I need to update the results from the following query:
select *
from table 1, table 2
where table1.field_ID = table2.field_ID
and table2.field_flag = 'y'

My problem is I can't get the syntax to update a field in table 2 above based on that criteria, but it's not working. In theory, this is what I need to do:
update table2
set table2.field = 999
where
(select *
from table 1, table 2
where table1.field_ID = table2.field_ID
and table2.field_flag = 'y')



Can anyone help me out? Thanks!
 
The following update string should work. I advise testing is on a backup copy of the data first.

Code:
update table2
Set    table2.Field = 99
From   Table2
       Inner Join Table1 On table1.field_id = table2.field1
Where  Table2.Field_Flag = 'y'

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top