Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8480151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:13:08+00:00 2026-06-10T19:13:08+00:00

I have the following table on a server: CREATE TABLE routes ( id int(11)

  • 0

I have the following table on a server:

CREATE TABLE routes (
  id          int(11) unsigned NOT NULL AUTO_INCREMENT,
  from_lat    double NOT NULL,
  from_lng    double NOT NULL,
  to_lat      double NOT NULL,
  to_lng      double NOT NULL,
  distance    int(11) unsigned NOT NULL,
  drive_time  int(11) unsigned NOT NULL,

  PRIMARY KEY (id),
  UNIQUE KEY route (from_lat,from_lng,to_lat,to_lng)
) ENGINE=InnoDB;

We are saving some routing information from point A (from_lat, from_lng) to point B (to_lat, to_lng). There is a unique index on the coordinates.

However, there are two entries in the database that confuse me:

+----+----------+----------+---------+---------+----------+------------+
| id | from_lat | from_lng | to_lat  | to_lng  | distance | drive_time |
+----+----------+----------+---------+---------+----------+------------+
| 27 | 52.5333  | 13.1667  | 52.5833 | 13.2833 | 13647    | 1125       |
| 28 | 52.5333  | 13.1667  | 52.5833 | 13.2833 | 13647    | 1125       |
+----+----------+----------+---------+---------+----------+------------+

They are exactly the same.

When I not try to export the database using mysqldump and trying to reimport it, I get an error:

ERROR 1062 (23000): Duplicate entry '52.5333-13.1667-52.5833-13.2833' for key 'route'

How can it be that this is in the database, when there is an unique key on them? Shouldn’t MySQL reject them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:13:09+00:00Added an answer on June 10, 2026 at 7:13 pm

    Is it possible that the double values are slightly different, but only after the 4th digit?
    If you export and import them, they would be the same, and that would give a unique constraint violation.

    Quoting from this MySQL bug report:

    When mysqldump dumps a DOUBLE value, it uses insufficient precision to
    distinguish between some close values (and, presumably, insufficient
    precision to recreate the exact values from the original database). If
    the DOUBLE value is a primary key or part of a unique index, restoring
    the database from this output fails with a duplicate key error.

    Try to display them with more digits behind the comma (how will depend on your client.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table CREATE TABLE [dbo].[LogFiles_Warehouse]( [id] [int] IDENTITY(1,1) NOT NULL, [timestamp]
Say i have the following table: create table T ( ID int not null
I have the following table: CREATE TABLE [dbo].[omgbbq]( [tbl_key] [int] IDENTITY(1,1) NOT NULL, [name]
I've got the following SQL table: CREATE TABLE [dbo].[Test]( [TestID] [int] NOT NULL, [TestNum]
I have the following table in SQL Server: CREATE TABLE [dbo].[Users]( [Id] [int] IDENTITY(1,1)
I have the following table: CREATE TABLE [dbo].[TableB]( [id] [int] NULL, [FileName] [varchar](20) NULL
I have following table CREATE TABLE User ( email sysname NOT NULL, sign varbinary(256)
In MICROSOFT SQL SERVER have the following table: CREATE TABLE [T1] ( [ID] int
I have the following table in SQL Server 2008: CREATE TABLE tbl (ID INT,
I have the following table definition: CREATE TABLE X ( A SOMETYPE NOT NULL,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.