Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Update value where values from two columns match one column value?

I am trying to update my mysql table (cityTable) with the cityFull value in administrativeTable where the cityCode values match country and city in cityTable.

I believe this statement should work. Only part that I am missing is what to put in the ???? for cityCode. It is a bit complicated as it also has a period (.)

UPDATE cityTable INNER JOIN administrativeTable ON (?????????? = administrativeTable.cityCode) SET cityTable.cityFull = administrativeTable.cityFull;

administrativeTable

+----------+-----------+
| cityCode | cityFull  |
+----------+-----------+
| AU.Melb  | Melbourne |
| NZ.Auck  | Auckland  |
+----------+-----------+

cityTable

+---------+------+-----------+
| country | city | cityFull  |
+---------+------+-----------+
| AU      | Melb |           |
| NZ      | Auck |           |
+---------+------+-----------+

Cheers!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need the function CONCAT():

UPDATE cityTable c
INNER JOIN administrativeTable a 
ON CONCAT(c.country, '.', c.city) = a.cityCode 
SET c.cityFull = a.cityFull;

See the demo.
Results:

| country | city | cityFull  |
| ------- | ---- | --------- |
| AU      | Melb | Melbourne |
| NZ      | Auck | Auckland  |
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!