Quantcast
Channel: Need to insert SQL without duplicates - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Need to insert SQL without duplicates

$
0
0

The table is currently this:

CREATE TABLE `feed_items` (  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,  `feed_id` int(11) NOT NULL,  `remote_id` varchar(32) NOT NULL DEFAULT '',  `title` varchar(255) NOT NULL DEFAULT '',  `link` varchar(255) NOT NULL DEFAULT '',  `updated_time` datetime NOT NULL,  `created_time` datetime NOT NULL,  PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;

I need to find a way so that if i pull multiple RSS feeds into one table, and articles with the same Title have the same value of 'remote_id', how can i make sure I do not insert a duplicate value?

I am currently using

$this->db->query('INSERT INTO feed_items(feed_id, remote_id, link, title, created_time, updated_time) VALUES (?, ?, ?, ?, ?, NOW()) ON DUPLICATE KEY UPDATE remote_id=remote_id', array($this->feed_id, $this->remote_id, $this->link, $this->title, $this->created_time, $this->remote_id));

I was wondering if there is a better way?


Viewing all articles
Browse latest Browse all 6

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>