Link to home
Start Free TrialLog in
Avatar of Fernanditos
Fernanditos

asked on

Dumping mysql table but skipping duplicated titles

Hi,

I have a book table (books_bok) with 3K titles. I want to dump another table (with exact same structure) but I want to avoid / skip duplicate titles.

What would be a good practice to do in this case ?

I attach the database structure in case it helps.

Thank you.
db.txt
Avatar of hernst42
hernst42
Flag of Germany image

You coulf try this:
CREATE TABLE new_books_bok SELECT DISTINCT * FROM books_bok;
Avatar of Fernanditos
Fernanditos

ASKER

I don't think it makes much sense since you do not specify the column I want to have unique: "title_bok" ?

Do you understand what I mean? makes sense?
ASKER CERTIFIED SOLUTION
Avatar of mankowitz
mankowitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, maybe this would work (didn't test it)

CREATE TABLE new_books_bok SELECT * FROM books_bok GROUP BY title_bok;

Open in new window

in case you want to have latest details for that perticular title you might use order by clause in above query:
CREATE TABLE new_books_bok SELECT * FROM books_bok GROUP BY title_bok order by id desc;