Question

I have a following table :

dct_cry_id............cry_id............dct_id..........classify........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

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 
)

And I have unfortunately, i have following warning/error message :

"! #1062 - Duplicate entry '222-104276' for key 'cry_id'"

Why I have a this message ?

After this, I checked my table, my query worked : dct_cry_id............cry_id............dct_id..........classify........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 (...)

Was it helpful?

Solution

Your query will return the key '222-104276' 4 times. The record was inserted once and error was raised on second insert.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top