我有一张桌子:

dct_cry_id ............ cry_id ............ dct_id .............分类........ dct_connection_id
(...)
71 ................................. 13 ............ 104276 ........... ... 70 .............. 0
2110 ............................... 29 ............ 104276 ............. .7 ...... 0
2111 ............................... 37 ......... 104276 ............. .8 ...... 0
2112 ...................... 38 ......... 104276 ...................... .6 ...... 0
(...)
591 ....................... 13 ......... 154614 ......... ..540 ............. 0
2090 ............................... 36 ......... 154614 ...................... .46 ......... 0
2091 ..................................... 30 ......... 154614 ...................... .2 ...... 0
(...)

我使用以下查询

I use following query
INSERT INTO mytabletest1 (cry_id,`dct_id`)
-- VALUES (222)
SELECT
222, `dct_id`

FROM `mytabletest1`
WHERE `cry_id`
NOT IN
(
112, 115, 116, 117, 118,
973, 974, 975, 976, 977,
8
)


不幸的是,我有以下警告/错误消息:


  “!#1062-密钥'cry_id'的重复条目'222-104276'”


为什么我有此消息?

在此之后,我检查了我的表,我的查询成功了:
dct_cry_id ............ cry_id ............ dct_id .............分类........ dct_connection_id
(...)
71 ................................. 13 ............ 104276 ........... ... 70 .............. 0
2110 ............................... 29 ............ 104276 ............. .7 ...... 0
2111 ............................... 37 ......... 104276 ............. .8 ...... 0
2112 ...................... 38 ......... 104276 ...................... .6 ...... 0
153876 .................... 222 ........... 104276 ....................... 0。 .............. 0
(...)
591 ....................... 13 ......... 154614 ......... ..540 ............. 0
2090 ............................... 36 ......... 154614 ...................... .46 ......... 0
2091 ..................................... 30 ......... 154614 ...................... .2 ...... 0
15870 ..................... 222 .............. 154614 .............. 0 ...... 0
(...)

最佳答案

您的查询将返回键“ 222-104276” 4次。记录被插入一次,并且在第二次插入时引发错误。

09-18 15:49