duplicates

MySQL Delete duplicates in consecutive rows

余生长醉 提交于 2019-12-10 18:54:04
问题 Suppose this table: ID ColA ColB 1 7 8 2 7 9 3 7 9 4 5 8 5 6 9 6 6 9 7 5 4 The PK is the ID coumn. Now, I want to delete all duplicates of ColA and ColB in consecutive rows. In this example rows 2,3 and 5,6 contain duplicates. These shall be removed so that the higher ID is remained. The output should be: ID ColA ColB 1 7 8 3 7 9 4 5 8 6 6 9 7 5 4 How can this be done with mySQL? Thanks, Juergen 回答1: SELECT ID FROM MyTable m1 WHERE 0 < (SELECT COUNT(*) FROM MyTable m2 WHERE m2.ID = m1.ID - 1

Array Unique with Associative Array - Remove Duplicates

我们两清 提交于 2019-12-10 18:24:25
问题 I've got an associative array with some duplicate items. For example, I have: <? $group_array = array('user_id'=>array(), 'user_first'=>array()); Which outputs something like below: Array ( [user_id] => Array ( [0] => 594 [1] => 597 [2] => 594 ) [user_first] => Array ( [0] => John [1] => James [2] => John ) ) I'd like to sanitize this entire array so that only the user John will show up once (based on user_id). I've tried the following: <?php $unique = array_unique($group_array); print_r(

Json.net no longer throws in case of duplicate

送分小仙女□ 提交于 2019-12-10 18:09:51
问题 I'm trying to upgrade my C# application from Newtonsoft.JSON 6 to the latest version (9.0.1). I noticed a change of behavior when deserializing object containing duplicate elements, such as : { "name": "test", "data": { "myElem": 1, "myElem": 2 } } When deserializing such object, Json.net was previously throwing an ArgumentException. Now the deserialization succeed and it seems that it uses the value of the last duplicated key (hence "2" in above example). From what I read, there is some

Remove duplicates from array of objects

*爱你&永不变心* 提交于 2019-12-10 18:08:03
问题 I have a class called Customer that has several string properties like firstName, lastName, email, etc. I read in the customer information from a csv file that creates an array of the class: Customer[] customers I need to remove the duplicate customers having the same email address , leaving only 1 customer record for each particular email address. I have done this using 2 loops but it takes nearly 5 minutes as there are usually 50,000+ customer records. Once I am done removing the duplicates

Swift - UICollectionView repeats (duplicate) cells

别来无恙 提交于 2019-12-10 17:38:36
问题 Hi I have an array with 100 pictures url's taken from flickr. When I use UICollectionView I display 100 cells, only 8 cells are on the screen and when I scroll down to see next 8 they are the same like the previous and when I execute func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! and println("something") it writes in console only 8 time something but the content of array is 100 I use this: func collectionView

MySQL delete all results of sub-query

和自甴很熟 提交于 2019-12-10 17:19:44
问题 Okay, so if you would like a back story, look at my previous question Figuring out which of my records is not a duplicate is quite easy: SELECT * FROM eventlog GROUP BY event_date, user HAVING COUNT(*) = 1 ORDER BY event_date, user This returns all of my non-duplicates. So I thought I'd move them over to another table called "no_duplicates" and then delete them from the original table. Then I could see the duplicates all alone in the original table, fix them up, and add the no_dupes back. But

Find lines in file that contain duplicate characters

偶尔善良 提交于 2019-12-10 17:17:08
问题 I need some help in locating lines in a text file that contain duplicate characters. I prefer using bash, but any other method will do fine :) A small example just to make things clear: file.txt: 1234 11234 abcd 12234 ab321 1233 zs11w 12w2 the desired output: 11234 12234 1233 zs11w 12w2 Thanks for all your help! 回答1: grep '\(.\).*\1' file.txt Matches any line that contains a character, any string, and then that same character, i.e. any line with duplicates. 回答2: Perl: perl -ne 'print if /(.)

Javascript return array from 2 arrays removing duplicates

有些话、适合烂在心里 提交于 2019-12-10 16:59:20
问题 Searched and tried and no luck so far. var newUsers = [{name: 'rich', id: 25}, {name: 'lauren', id: 35}, {name: 'dave', id: 28} ] var likedUsers = [{name: 'derek', id: 39}, {name: 'rich', id: 25}, {name: 'brian', id: 38} ] What I want returned is: var leftUsers = [{name: 'lauren', id: 35}, {name: 'dave', id: 28} ] basically without the rich object as this is a duplicate. I only care about the id key. I have tried: newUsers.forEach((nUser) => { likedUsers.forEach((lUser) => { if (nUser.id !==

SQL duplicate rows with multiple left joins

扶醉桌前 提交于 2019-12-10 16:47:37
问题 I'm currently facing the following problem: I have 3 tables I need information from and both of these joins are one to many. For some reason second join creates duplicates of rows and as a result second return value gets messed up (bb.count gets multiplied by the amount of second join rows) SELECT aa.id, sum(bb.count), count(DISTINCT cc.id) FROM aaaa aa LEFT JOIN bbbb bb ON bb.aa_id = aa.id LEFT JOIN cccc cc ON cc.bb_id = bb.id GROUP BY aa.id Is there a way to get the proper sum of bb.count

PHP - remove duplicate syllable word

馋奶兔 提交于 2019-12-10 16:34:19
问题 i'm new and wanna know how to using regex in php. if i have text like "haha" "abcabcabc" "hehehe" "cupcupcupcup" (contain duplicate of syllable word). How to remove that text? (say $text="cupcupcup"; ", how to make this like $text=""; ) sorry if there is same ask (i have search, but cant find page that describe my issue) thanks for your appreciate. :) 回答1: Try $txt = preg_replace("/^(.*)(\\1+)$/", "", $txt); This searches for a sequence at the start of the string, then matches at least one