如果 matchid 和 videoset 字段等于当前值,我将如何插入行或更新行?这是我到目前为止所拥有的,如果我在一个空表上运行两次,我希望 3 行结果应该是返回的总量。当我运行此查询两次时,它不会像预期的那样更新之前添加的 3 条记录,查询只会添加另外 3 个结果。在这方面的任何知识都将受到高度赞赏。谢谢!
INSERT INTO videos (matchid, youtubecode, videoid, videoset) VALUES
(96, "Blahblahblah", '', '1'),
(96, "WEEEEEE", '', '2'),
(96, "glgkgklbgjbgklbj", '', '3')
on duplicate key update matchid=values(videoset) AND videoset=values(videoset)
/*Column Information*/
----------------------
Field Type Collation Null Key Default Extra Privileges Comment
----------- ------------ ----------------- ------ ------ ------- -------------- ------------------------------- ---------
matchid int(10) (NULL) YES MUL (NULL) select,insert,update,references
youtubecode varchar(300) latin1_swedish_ci NO (NULL) select,insert,update,references
videoid int(11) (NULL) NO PRI (NULL) auto_increment select,insert,update,references
videoset int(11) (NULL) YES MUL (NULL) select,insert,update,references
/*Index Information*/
---------------------
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
------ ---------- -------- ------------ ----------- --------- ----------- -------- ------ ------ ---------- ------- ---------------
videos 0 PRIMARY 1 videoid A 6 (NULL) (NULL) BTREE
videos 1 matchid 1 matchid A 2 (NULL) (NULL) YES BTREE
videos 1 videoset 1 videoset A 6 (NULL) (NULL) YES BTREE