@
@
@atambalasi2016-02-26 14:03:35
PHP
@atambalasi, 2016-02-26 14:03:35

How to insert unique values ​​into a table?

There is a table with coordinates
lat float
lng float
How to write an INSERT so that the data does not repeat.
Now I am able to insert non-repeating data like this
. I take all the records in PHP and take the data that needs to be inserted (they can be from 0 to 50 maximum at a time) and compare them. This option does not suit me because there can be more than a million records. Is there a way to write a more optimal INSERT ?
And if the lat lng fields are designated as UNIQUE mysql will drive itself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fixid, 2016-02-26
_

If I understand correctly, then insert ignore will help

A
Andrey, 2016-02-26
@VladimirAndreev

two fields one unique index and forward

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question