Reputation: 2704
Here's the error I'm shown when performing the SQL Query in question
#1062 - Duplicate entry '67302165' for key 'Player_Resource'
I understand this means that the record already exists, but it actually doesn't, here's what's returned when I run a SELECT
query, to check against that specific Player_Resource
SELECT * FROM `players` WHERE `Player_Resource` = '67302165'
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0003 sec)
And as for the INSERT
query that I'm trying to perform, it's as followed;
INSERT INTO
`players`
(
`Player_ID`,
`Player_Resource`,
`Player_Name`,
`Player_Common`,
`Player_Club`,
)
SELECT
`Player_ID`,
'67302165',
Player_Name,
Player_Common,
Player_Club,
FROM
`players`
WHERE
`Player_ID` = '193301'
The table description is like such
| Field | Type | Null | Key | Default | Extra |
+----------------+----------------+----------+---------+---------+------------------+
Players_id int(11) NO PRI NULL auto_increment
Player_ID int(6) NO 0
Player_Resource varchar(255) NO UNI 0
Player_Name varchar(255) NO NULL
Player_Common varchar(255) NO NULL
Player_Club int(10) NO NULL
Any explainable reason as to why this error would be shown? bare in mind I've placed a UNIQUE
Index on the Player_Resource
column
Upvotes: 1
Views: 162
Reputation: 31903
You seem to have more than one row in that table with Player_ID=193301
. The fact that they have a different Player_Resource
doesn't matter because you never use the actual value in your insert query. You use the fixed value of 67302165
in all insertions:
...
SELECT
`Player_ID`,
'67302165',
Player_Name,
Player_Common,
Player_Club,
FROM
`players`
...
Upvotes: 1