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

253
Views
Update table from converted value in another table

I'm trying to compare between an int value and a converted (varchar to INT) value in one table to find a value in another table then update it through phpmyadmin.

comment table

id: 1   title:Lorem   postID: 15 

meta table

ID:99   NewID: 123 Type: "older_id"   Value:"15"

SQL

update t1
set t1.postID = t2.NewID
from comment t1
inner join meta t2
on t1.postID = CAST(t2.value AS INT)
where t2.Type = "older_id";

I'm not sure what i'm doing wrong but i keep getting an error.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you are using MySQL (which is typical with PHP), then the right syntax is:

update comment c join
       meta m
       on c.postId = (p2.value + 0)  -- this converts the value, although even this is not necessary
    set c.postID = m.NewID
    where m.Type = 'older_id';

There is no from clause in MySQL.

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!