mysql - How do I assign the same id to rows having the same field -
i have mysql table containing 2553 novels information (like author, year etc.), , table containing 1059 authors (with biographical informations).
now, authors in second table writers of novels in first table. i'd assign same id authors in first table second table ones.
how can do? tried doing without success.
this how 'novels' table should (at moment there isn't author_id column)
__ _____ ______ _________ |id|title|author|author_id| |0 |xyz |john |0 | |1 |xyz2 |john |0 | |2 |abc |rob |1 | |3 |qwer |jeff |2 | |4 |zxcv |jeff |2 | |_________________________|
this 'authors' table
__ ____ _____ |id|name|birth| |0 |john|1956 | |1 |rob |1898 | |2 |jeff|1932 | |_____________|
you can update join.
update novels inner join authors set novels.author_id=authors.id novels.author=authors.name
there after should want drop author column in novels table since becomes redundant (assuming of course authors correctly represented in authors table)
Comments
Post a Comment