2

I have two tables

  1. titles_downloads
  2. title_history

Currently i am saving idtitle_history in titles_downloads as a column. The title_history has a column idtitle which is different from idtitle_history.

I want to change the idtitle_history in my titles_downloads table to idtitle

Example data for title_history table

       idtitle_history                 idtitle
            1                             160
            2                             210
            3                             345

titles_downloads

       iddownloads                      idtitle_history
            1                              1
            2                              2
            3                              3

I want to replace the idtitle in this table to 160, 210, 345 ...

Thanks

4

2 回答 2

1

尝试

update titles_downloads
inner join title_history 
on title_history.idtitle_history  = titles_downloads.idtitle_history 
set idtitle_history = title_history.idtitle
于 2012-07-04T10:04:00.363 回答
0

尝试这个:

UPDATE titles_downloads td
JOIN title_history th ON td.iddownloads = th.iddownloads
SET th.iddownloads = td.idtitle
于 2012-07-04T10:04:32.723 回答