duanjing4623 2012-12-18 00:30
浏览 26
已采纳

如果存在两个值,则不插入PHP / SQL

I only want to insert if there are no entries where "name" and "email" exist together.

So it's ok if "name" exists with a different e-mail or vica versa.

mysql_query("INSERT INTO list (name,email) VALUES ('$name','$email') ");

I want this done in one SQL statement for bette performance.

  • 写回答

4条回答 默认 最新

  • douding6266 2012-12-18 00:36
    关注

    Make both the columns (name,email) as composite primary key and use ON DUPLICATE KEY UPDATE to prevent php errors.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?