MySQL update from one table to another with condition not working?

前端 未结 3 869
灰色年华
灰色年华 2021-01-03 03:10

I have tried a solution that seems to work for someone else on this question:

Update table a from table b where (conditions) I can not seem to get it working, MySql

相关标签:
3条回答
  • 2021-01-03 03:45

    Try this:

    UPDATE video_data SET date_timestamp = (SELECT video.date_timestamp FROM video WHERE  video.video_id = video_data.video_id)
    

    Although the error in your actual query is simply that you missed a "SELECT"

    UPDATE video_data SET video_data.date_timestamp = SELECT video.date_timestamp FROM video_data JOIN video ON video_data.video_id = video.video_id
    

    But I don't think it is what you want it to be.

    0 讨论(0)
  • 2021-01-03 03:50

    Try this syntax out:

    UPDATE video_data, video 
    SET video_data.date_timestamp = video.date_timestamp
    WHERE  video_data.video_id = video.video_id
    
    0 讨论(0)
  • UPDATE video_data, video SET video_data.date_timestamp = video.date_timestamp
    WHERE video_data.video_id = video.video_id
    
    0 讨论(0)
提交回复
热议问题