企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
业务场景:需要记入访客的访问情况,但不能重复记入 ***** 可以插入前进行判断要插入的数据是否存在业务代码如下 : INSERT INTO t_topic_vistor(user_id,topic_code) SELECT '218', 'XQ33019920170811142528217' FROM DUAL WHERE NOT EXISTS(SELECT * FROM t_topic_vistor WHERE user_id = 218 and topic_code='XQ33019920170811142528217') ***** 语法如下: test_sql="INSERT INTO table(field1, field2, fieldn) SELECT 'field1', 'field2', 'fieldn' FROM DUAL WHERE NOT EXISTS(SELECT field FROM table WHERE field = ?)" 然后直接执行这条语句就可以 如python里 cursor.execute(test_sql) *****