duplicate-data

Remove Duplicates with Caveats

喜夏-厌秋 提交于 2019-12-03 21:06:06
I have a table with rowID, longitude, latitude, businessName, url, caption. This might look like: rowID | long | lat | businessName | url | caption 1 20 -20 Pizza Hut yum.com null How do I delete all of the duplicates, but only keep the one that has a URL (first priority), or keep the one that has a caption if the other doesn't have a URL (second priority) and delete the rest? Here's my looping technique. This will probably get voted down for not being mainstream - and I'm cool with that. DECLARE @LoopVar int DECLARE @long int, @lat int, @businessname varchar(30), @winner int SET @LoopVar =

How can I compare two tables and delete the duplicate rows in SQL?

假如想象 提交于 2019-12-03 13:25:46
问题 I have two tables and I need to remove rows from the first table if an exact copy of a row exists in the second table. Does anyone have an example of how I would go about doing this in MSSQL server? 回答1: Well, at some point you're going to have to check all the columns - might as well get joining... DELETE a FROM a -- first table INNER JOIN b -- second table ON b.ID = a.ID AND b.Name = a.Name AND b.Foo = a.Foo AND b.Bar = a.Bar That should do it... there is also CHECKSUM(*) , but this only

Removing contiguous duplicate lines in vi without sorting

心已入冬 提交于 2019-12-03 08:17:15
问题 This question already addresses how to remove duplicate lines, but enforces that the list is sorted first. I would like to perform the remove contiguous duplicate lines step (i.e. uniq ) without first sorting them. Example before: Foo Foo Bar Bar Example after: Foo Bar 回答1: Just found the solution here. The following regex works correctly: g/^\(.*\)$\n\1$/d 回答2: :%!uniq if you're on a unix system, or a system that has the uniq program 回答3: If you want to remove non-contiguous duplicates you

How to remove the quoted text from an email and only show the new text

对着背影说爱祢 提交于 2019-12-03 06:01:09
问题 I am parsing emails. When I see a reply to an email, I would like to remove the quoted text so that I can append the text to the previous email (even if its a reply). Typically, you'll see this: 1st email (start of conversation) This is the first email 2nd email (reply to first) This is the second email Tim said: This is the first email The output of this would be "This is the second email" only. Although different email clients quote text differently, if there were someway to get mostly the

SQL Remove almost duplicate rows

走远了吗. 提交于 2019-12-03 03:41:55
I have a table that contains unfortuantely bad data and I'm trying to filter some out. I am sure that the LName, FName combonation is unique since the data set is small enough to verify. LName, FName, Email ----- ----- ----- Smith Bob bsmith@example.com Smith Bob NULL Doe Jane NULL White Don dwhite@example.com I would like to have the query results bring back the "duplicate" record that does not have a NULL email, yet still bring back a NULL Email when there is not a duplicate. E.g. Smith Bob bsmith@example.com Doe Jane NULL White Don dwhite@example.com I think the solution is similar to Sql,

How can I compare two tables and delete the duplicate rows in SQL?

冷暖自知 提交于 2019-12-03 03:33:48
I have two tables and I need to remove rows from the first table if an exact copy of a row exists in the second table. Does anyone have an example of how I would go about doing this in MSSQL server? Well, at some point you're going to have to check all the columns - might as well get joining... DELETE a FROM a -- first table INNER JOIN b -- second table ON b.ID = a.ID AND b.Name = a.Name AND b.Foo = a.Foo AND b.Bar = a.Bar That should do it... there is also CHECKSUM(*) , but this only helps - you'd still need to check the actual values to preclude hash-conflicts. If you're using SQL Server

Removing contiguous duplicate lines in vi without sorting

我的梦境 提交于 2019-12-02 20:53:56
This question already addresses how to remove duplicate lines, but enforces that the list is sorted first. I would like to perform the remove contiguous duplicate lines step (i.e. uniq ) without first sorting them. Example before: Foo Foo Bar Bar Example after: Foo Bar Just found the solution here . The following regex works correctly: g/^\(.*\)$\n\1$/d :%!uniq if you're on a unix system, or a system that has the uniq program If you want to remove non-contiguous duplicates you could use :g/^\(.*\)\ze\n\%(.*\n\)*\1$/d (which will remove all but the last copy of a line) which would change Foo

How to remove the quoted text from an email and only show the new text

馋奶兔 提交于 2019-12-02 19:27:49
I am parsing emails. When I see a reply to an email, I would like to remove the quoted text so that I can append the text to the previous email (even if its a reply). Typically, you'll see this: 1st email (start of conversation) This is the first email 2nd email (reply to first) This is the second email Tim said: This is the first email The output of this would be "This is the second email" only. Although different email clients quote text differently, if there were someway to get mostly the new email text only, that would also be acceptable. I use the following regex(s) to match the lead in

How to check duplicates name in android database?

拟墨画扇 提交于 2019-12-02 07:25:36
问题 I want to enter name and phone number from two edit text.i use two buttons to save and show it in emulator using list view.After entering name and when i click save button how to check whether i have already entered the same name. i am new to android explanation will be really helpful. public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE "+tbname+"("+Key_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "+Key_name+" TEXT,"+Key_mobile+" TEXT)"); } public void n(String aa, String bb) {

How to check duplicates name in android database?

偶尔善良 提交于 2019-12-02 03:56:44
I want to enter name and phone number from two edit text.i use two buttons to save and show it in emulator using list view.After entering name and when i click save button how to check whether i have already entered the same name. i am new to android explanation will be really helpful. public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE "+tbname+"("+Key_id+" INTEGER PRIMARY KEY AUTOINCREMENT, "+Key_name+" TEXT,"+Key_mobile+" TEXT)"); } public void n(String aa, String bb) { SQLiteDatabase db=this.getWritableDatabase(); ContentValues cv=new ContentValues(); cv.put(Key_name, aa);