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

How do I write this SQL statement?

Status
Not open for further replies.

jruiseco

Programmer
Oct 10, 2001
52
US
I have two tables (see below). Table 'csv' has the data I want to put into Table 'item'.

How do I write the SQL statement to update item.Manufac with the data in csv.Manufac? I've started out with something like this:

update item
set item.manufac = csv.Manufac
where item.ItemNo = csv.itemNo

<!-- Example tables -->

csv.ItemNo csv.Manufac

1234 1
1235 3
1236 4
1237 9
1238 3
1239 1


item.ItemNo item.Manufac

1234 0
1235 0
1236 0
1237 0
1238 0
1239 0



 
update item
set item.manufac = csv.Manufac
from item, csv
where item.ItemNo = csv.itemNo
 
I recommend ANSI syntax.

Update item
Set manufac = csv.Manufac
From item INNER JOIN csv
on item.ItemNo = csv.ItemNo

NOTE: in SQL 2000, Set tablename.colname = <value> will cause an error. You need to leave off the table name from the destination column. Set colname = <value> Terry L. Broadbent
Programming and Computing Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top