Thursday, July 22, 2010
Google Docs Bug - Paste Not Working In Spreadsheet
I have tried to copy and paste part of a table from Excel 2007 to Google Docs using Chrome 6.0.472.0 dev. Unfortunately when I used right-click and chose paste it didn't work, neither did it work when I used the menu Edit and chose Paste. But ctrl+v worked! This also happend in Firefox 3.6.7.
Friday, March 19, 2010
Add Unique Index in MySQL and Remove Duplicated Data Automatically using "IGNORE" Keyword
I have been trying to remove some duplicated data in MySQL and have been trying different approaches. Of course you can run a very complicated query but if a column or a few columns should only have unique values you really should build a unique index. The benefit of this is not only that you don't have to manually run a complicated query, but the data integrity will be ensured in the future.
You can run this script to build a unique index:
ALTER TABLE `table` ADD UNIQUE INDEX `name_of_index` (`unique_column` ASC);
The only problem is that if you already have duplicated data(in this case if you have multiple rows that have the same value in column unique_column), this script will chuck an error:
ERROR 1062: Duplicate entry 'some_value' for key 'name_of_index'
The trick we're missing here is actually quite simple - simply add "IGNORE" keyword in your script:
All duplicated data will then be automatically removed to ensure data is unique in the column(s) on which the unique index is being built.
Job done:)
Thanks to the comment posted by Evan XX.
Subscribe to:
Posts (Atom)