Jump to content

Join two tables on a similar field


grippat
 Share

Recommended Posts

I'm trying to figure out how to join two MySQL tables on a similar field in an update. I have one table "Companies" and another "Territories" that don't share an identical field, however they both have zip code fields. The one in Companies is 5 digits plus 4 like 12345-1234 and the one in Territories is just 5 digits like 12345. Is there a way I can do this? Would I be able to do something like this:

UPDATE Companies coJOIN Territories trON tr.zipcode LIKE co.zip SET co cust_sales_rep = tr.sales_rep_id

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...