From: Joerg Bruehe Date: February 15 2011 6:58pm Subject: Re: Insert only if the entry doesn't exist List-Archive: http://lists.mysql.com/mysql/224417 Message-Id: <4D5ACCE0.5080402@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Hi! Andre Polykanine wrote: > Hello Rolando, >=20 > So if I do > "INSERT IGNORE INTO `Votes` SET `EntryId`=3D'12345', UserId`=3D'789'"; > it *won't* insert the second row if there's a row with EntryId set to > 12345 and UserId set to 789? If you want to have at most one vote per user on any entry, IMO you should have a "unique index" on that combination of fields. Aside: Assuming you "*Id" values are numeric types, you should stop using quotes around them: quotes enclose strings. I know MySQL implicitly converts numbers to strings and vice versa, but this costs performance and IMO is a bad idea anyways. I feel a programmer should know the distinction of numeric and string types and keep them separate in a well-structured application. HTH, J=F6rg --=20 Joerg Bruehe, MySQL Build Team, joerg.bruehe@stripped ORACLE Deutschland B.V. & Co. KG, Komturstrasse 18a, D-12099 Berlin Geschaeftsfuehrer: Juergen Kunz, Marcel v.d. Molen, Alexander v.d. Ven Amtsgericht Muenchen: HRA 95603