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

Update rows in a table using a list of ID values

Status
Not open for further replies.

matpj

Technical User
Mar 28, 2001
687
GB
I have a table in which I need to update certain rows.

the key field in the table is Proj_ID.
another process creates a table that lists projects that need updating.

how do I write some SQL to do this.

the script needs to be something like.

UPDATE <table1>
SET <table1>.<value> = "CLI"
WHERE <table1>.Proj_ID In <table containing list of project ids>

this syntax doesn't seem to work though.

any ideas?

thanks,
Matt
 
try:

UPDATE tbl1
SET blah = 'Blah'
WHERE tbl1.ProjID IN (Select ProjID FROM tbl2);
 
hmm, that works.
dunno why it didn't work before. might be because I didn't put the table in square brackets (it had a space in its title)

thanks for that.
 
yes, that would probably give you a syntax error, personally I never include spaces in any names...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top