Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Im trying to do an UPDATE statement.

UPDATE `users` SET
`Email` = 'email@domain.com',
`Mobile` = '123456789',
`City` = 'Chicago',
`Firstname` = 'John',
`Lastname` = 'Smith',
`DOB` = '1980-01-01',
`Sex` = 'male'

#1062 - Duplicate entry '123456789' for key 'Mobile'

But I'm updating the record with the same mobile number. Why will it not accept ? I think I got to do something on the lines of UPDATE table ON DUPLICATE KEY update-other-fields.

share|improve this question
3  
You need a where clause, that statement attempts to update the whole table with those values! – Mat Dec 10 '12 at 12:16
My bad - yes - this requires a WHERE. Thanks. – EPQRS Dec 10 '12 at 12:18
1  
@Mat should add his comment as an answer and EPQRS should accept this answer. otherwise this query will be found in the list pf queries without an answer. – miracle173 Dec 10 '12 at 14:23

closed as too localized by RolandoMySQLDBA, Derek Downey, ypercube, Paul White, Mark Storey-Smith Dec 10 '12 at 17:00

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.