Reputation: 339
Here I have an mysql tables with ID, ID_polja, lat, lng:
As you can see I want to get first data from unique number so first (lat,lng) with ID_polja =1
first (lat,lng) with ID_polja = 2 ...
But how to run a query for that?
SELECT * FROM koordinate WHERE ID_polja=[1,2,3... n]
Upvotes: 2
Views: 84
Reputation: 36
As per my understanding you need unique data of lat and long from multiple ID_polja.
So try below query :-
SELECT * FROM koordinate WHERE ID_polja IN (1,2,3,...N) GROUP BY ID_polja;
OR
If you do not have any where condition you should use below query :-
SELECT * FROM koordinate GROUP BY ID_polja;
Upvotes: 1
Reputation: 39724
Maybe GROUP
and ORDER
:
SELECT * FROM `koordinate` GROUP BY `ID_polja` ORDER BY `ID` ASC
Upvotes: 3
Reputation: 295
SELECT INSTINCT ID_polja, ID, lat, Ing FROM koordinate
Thats the simplest solution. If you would use WHERE ID_polja IN [1,2,3]
you would have to count each and every number and it would still select every entry.
Upvotes: 1