我试图创建电子邮件数据使用mysql程序如果数据已经存在,我怎么能不插入我的电子邮件表呢?

yeotifhr  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(137)

我发现的大多数帖子都涉及到使用php,但我的案例中没有使用php。这是我的mysql程序

CREATE DEFINER=`root`@`localhost` PROCEDURE `create_email`(in UID_ int(20),
                                in user_id_ int(20),
                                in from_email_ VARCHAR(1024), 
                                in subject_email_ TINYTEXT, 
                                in body_email_ LONGTEXT, 
                                out id_ BIGINT(20) unsigned )
BEGIN
    set id_=0;
    INSERT INTO emails (UID, user_id, from_email, subject_email, body_email)
    VALUES
        (UID_ ,user_id_, from_email_, subject_email_, body_email_);
    set id_ = LAST_INSERT_ID();
END

当前,我的过程不检查表中的数据是否存在,它只在接收数据时插入。什么是确保收到的电子邮件数据不会在我的电子邮件表上重复的有效方法?
先谢谢你。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题