I have three tables: menu_tab has columns (menu_id,menu_description) item_tab has columns (item_id,item_name,item_description,item_price) menu_has_item has columns{ (menu_tab_menu_id ---> which is foreign key to menu_id (pk in menu_tab)), item_tab_item_id --- which is foreign key to item_id (pk in item_tab))4
there will be 2 kinds of duplicates which will be encountered 1)Item duplicate in the same menu_description 2)Item duplicate in a different menu description
Example: Two Chicken Sandwiches in the lunch menu. One Chicken Sandwich in Lunch and another in Dinner menu _description
menu_tab
menu_id menu_description
1 lunch
2 dinner
3 Specials
item_tab
item_id item_description
1 b
2 d
3 g
4 x
5 g delete g
6 d
7 e
8 b delete b
9 x
menu_has_tab
menu_tab_menu_id item_tab_item_id
1............................1
1............................2
1............................3
1............................4
2............................5 replace by 3
2............................6
3............................7
3............................8 replace by 1
3............................9
How do I update my menu_has_item with the replaced values after removing the duplicates?
i did this for my tables Rout(RoutID,SourceCityID,DestCityID) and Form(FormID,RoutID,...) i deleted duplicated routs from table Rout and update RoutID in Form table
first get the Duplicate Rows grouped by columns that u want to compare for duplicate
then get all duplicated rows without grouping and with columns that will be compared for duplicate
and then Update Form tbl like below:
and now delete the rows in Rout that arent in table Form
first you need replace your duplicates in menu_tab with new value
after that you need remove duplicates from item table you can found script there http://sprogram.com.ua/en/articles/oracle-delete-duplicate-record
ups you mark question as plsql and I mistakelly think that you about Oracle, sorry. but I supose in MySQL exists merge statement good luck