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!

Need help with an SQL Update

Status
Not open for further replies.

jonsan

Technical User
Jan 25, 2005
17
US
UPDATE Table1 SET Table1.FieldX = TRUE WHERE (Left(Table2.FieldY,3) = '000') AND (Right(Table2.FieldZ,7) = Right(Table1.FieldZ,7))

Will this work? Do I need to use a JOIN statement to test the fields from each record in Table2?

Thanks!
 
Do I need to use a JOIN statement
Yes, perhaps like this:
UPDATE Table1 INNER JOIN Table2 ON Right(Table1.FieldZ,7) = Right(Table2.FieldZ,7)
SET Table1.FieldX = TRUE
WHERE Left(Table2.FieldY,3) = '000';

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PH! Can more than one field be used for the join? So can I set up something like this:

UPDATE Table1 INNER JOIN Table2 ON (Table1.FieldY = Table2.FieldY) AND (Table1.FieldX = Table2.FieldX)...

?

Thanks!
 
Yes

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top