I've been using a Drupal module called FeedAPI De-Dupe to remove duplicate records from my site's (MySQL) database. The module does a great job, but I'm still left with some "duplicates" when the URLs sometimes contain "www" and sometimes don't. The code handling the duplicate detection is:
case 0: //url-based
$sql = "SELECT n.nid
FROM {node} n
INNER JOIN {feedapi_node_item} i ON i.nid=n.nid
WHERE type='%s' AND url = '%s'
LIMIT 1";
$dnid = db_result(db_query($sql,
variable_get('feedapi_dedupe_content_type', feedapi_dedupe_content_type()),
$url));
break;
Is there a way to modify the SQL to also handle the www/no-www case? If not, is there a way to handle it in a separate SQL query instead?