Toni Michel Caubet
Toni Michel Caubet

Reputation: 20183

insert ignore won't ignore

This code: would allways insert the Row, never detect that exists

$r =  mysql_query("INSERT IGNORE INTO facebook (uid,fid) VALUES ('".$_SESSION['id']."','".$persone['id']."')") or die(mysql_error());

why?

Edit: Please not, the input vales are allways the same

Upvotes: 0

Views: 166

Answers (1)

Kosta
Kosta

Reputation: 1867

INSERT IGNORE works on primary key fields only. If your facebook table does not have primary key set, you can do it like this:

alter table facebook add primary key (uid)

After this, INSERT IGNORE won't insert duplicated lines.

Upvotes: 3

Related Questions