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

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -