Editing Data cleaning

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 363: Line 363:
  
 
==== MySQL ====
 
==== MySQL ====
===== Finding duplicate rows that differ in one column =====
+
 
 
Find the duplicated data for one column<ref>[http://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql?rq=1 Finding duplicate values in MySQL - Stack Overflow]</ref>
 
Find the duplicated data for one column<ref>[http://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql?rq=1 Finding duplicate values in MySQL - Stack Overflow]</ref>
 
<pre>
 
<pre>
Line 393: Line 393:
 
</pre>
 
</pre>
  
===== Finding duplicate rows that differ in multiple columns =====
 
 
Using {{kbd | key =CONCAT}} for multiple columns ex: column_1, column_2  
 
Using {{kbd | key =CONCAT}} for multiple columns ex: column_1, column_2  
<pre>
 
SELECT count(*) count, CONCAT(  `column_1`, `column_2`  ) 'key'
 
FROM `table_name`
 
GROUP BY CONCAT(  `column_1`, `column_2`  )
 
HAVING count > 1;
 
</pre>
 
 
or
 
 
<pre>
 
<pre>
 
SELECT tmp.key FROM
 
SELECT tmp.key FROM
Line 413: Line 404:
 
</pre>
 
</pre>
  
===== other cases =====
 
 
For counting purpose: find the count of repeated id (type: int) between table_a and table_b
 
For counting purpose: find the count of repeated id (type: int) between table_a and table_b
 
<pre>
 
<pre>

Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see LemonWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)