duplicate-data

Best way to remove duplicate entries from a data table

不问归期 提交于 2019-11-26 08:14:16
What is the best way to remove duplicate entries from a Data Table? Remove Duplicates public DataTable RemoveDuplicateRows(DataTable dTable, string colName) { Hashtable hTable = new Hashtable(); ArrayList duplicateList = new ArrayList(); //Add list of all the unique item value to hashtable, which stores combination of key, value pair. //And add duplicate item value in arraylist. foreach (DataRow drow in dTable.Rows) { if (hTable.Contains(drow[colName])) duplicateList.Add(drow); else hTable.Add(drow[colName], string.Empty); } //Removing a list of duplicate items from datatable. foreach (DataRow

How do I find duplicate values in a table in Oracle?

帅比萌擦擦* 提交于 2019-11-26 02:39:31
问题 What\'s the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table? For example: I have a JOBS table with the column JOB_NUMBER . How can I find out if I have any duplicate JOB_NUMBER s, and how many times they\'re duplicated? 回答1: SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name HAVING COUNT(column_name) > 1; 回答2: Another way: SELECT * FROM TABLE A WHERE EXISTS ( SELECT 1 FROM

How to remove duplicate values from an array in PHP

家住魔仙堡 提交于 2019-11-25 22:33:36
问题 How can I remove duplicate values from an array in PHP? 回答1: Use array_unique(). Example: $array = array(1, 2, 2, 3); $array = array_unique($array); // Array is now (1, 2, 3) 回答2: //Find duplicates $arr = array( 'unique', 'duplicate', 'distinct', 'justone', 'three3', 'duplicate', 'three3', 'three3', 'onlyone' ); $unique = array_unique($arr); $dupes = array_diff_key( $arr, $unique ); // array( 5=>'duplicate', 6=>'three3' 7=>'three3' ) // count duplicates array_count_values($dupes); // array(

How to remove duplicate values from a multi-dimensional array in PHP

China☆狼群 提交于 2019-11-25 21:37:53
问题 How can I remove duplicate values from a multi-dimensional array in PHP? Example array: Array ( [0] => Array ( [0] => abc [1] => def ) [1] => Array ( [0] => ghi [1] => jkl ) [2] => Array ( [0] => mno [1] => pql ) [3] => Array ( [0] => abc [1] => def ) [4] => Array ( [0] => ghi [1] => jkl ) [5] => Array ( [0] => mno [1] => pql ) ) 回答1: Here is another way. No intermediate variables are saved. We used this to de-duplicate results from a variety of overlapping queries. $input = array_map(