-- WebTags-DeleteDuplicates.sql
/*
2012-12-10 Tom Holden ve3meo

Repeated use of WebTags-Consolidate.sql will result in duplicate WebTags
as may some other operations. This query eliminates the duplicates
by copying the unique WebTags to a temporary table, deleting all records 
from URLTable, and copying the records from the temporary table back
into URLTable.
*/

DROP TABLE IF EXISTS tmpURLTable
;

CREATE TEMP TABLE IF NOT EXISTS tmpURLTable AS

SELECT DISTINCT
  NULL AS LinkID,
  OwnerType,
  OwnerID,
  LinkType,
  Name,
  URL,
  Note
  FROM URLTable
;

DELETE FROM URLTable
;

INSERT INTO URLTable
SELECT * FROM tmpURLTable
;

DROP TABLE IF EXISTS tmpURLTable
;
