Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Android Contacts – Working With Duplicates

Posted on March 26, 2014October 26, 2015 By David Kittell

While this line is not necessary it’s a good idea to limit to this initially until you are ready to run on a larger scale.

AND data1 LIKE "%<Organization Name>%"
SELECT _id
	,raw_contact_id
	,data1
	,data4
	,data5
FROM data
WHERE mimetype_id IN (
		SELECT _id
		FROM mimetypes
		WHERE mimetype LIKE "%organization%"
		)
	AND data1 LIKE "%<Organization Name>%"
	AND raw_contact_id IN (
		SELECT raw_contact_id
		FROM data
		WHERE mimetype_id IN (
				SELECT _id
				FROM mimetypes
				WHERE mimetype LIKE "%organization%"
				)
		GROUP BY raw_contact_id
		HAVING count(raw_contact_id) > 1
		);
DELETE
FROM data
WHERE _id IN (
		SELECT max(_id) AS _id
		FROM data
		WHERE
			data1 LIKE "%<Organization Name>%"
			AND raw_contact_id IN (
				SELECT raw_contact_id
				FROM data
				WHERE mimetype_id IN (
						SELECT _id
						FROM mimetypes
						WHERE mimetype LIKE "%organization%"
						)
				GROUP BY raw_contact_id
				HAVING count(raw_contact_id) > 1
				)
		);
Originally Posted on March 26, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Android SQLite Code

Post navigation

Previous post
Next post

Related Posts

Remotely Find Raspberry Pi IP

Posted on October 13, 2015October 13, 2015

First install nmap sudo apt-get install nmap Then run IP addr show and look for something like ‘inet 10.1.1.68/24 brd 10.1.1.255’ ip addr show eth0 Now based on the inet IP CIDR type sudo nmap -sn 10.1.1.68/24 You should see something like this Nmap scan report for 10.1.1.54 Host is…

Read More

C# String Like

Posted on March 15, 2014October 26, 2015

I had a need to find a string like function similar to MSSQL and found this useful function. public static bool StringLike(this string toSearch, string toFind) { return new Regex(@"A" + new Regex(@".|$|^|{|[|(|||)|*|+|?|").Replace(toFind, ch => @"" + ch).Replace(‘_’, ‘.’).Replace("%", ".*") + @"z", RegexOptions.Singleline).IsMatch(toSearch); } bool willBeTrue = StringLike("abcdefg","abcd_fg"); bool willAlsoBeTrue…

Read More

Ubuntu – Require Sudo Rights To Shutdown

Posted on November 28, 2017

If you are working with UNIX and you need to remove the ability for normal users to shutdown you can make this file change. This change will simply require a user with sudo access to type in their password before the machine can shutdown. sudo cp /usr/share/polkit-1/actions/org.freedesktop.login1.policy /usr/share/polkit-1/actions/org.freedesktop.login1.policy.orig There’s a…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes