2

Here I have an mysql tables with ID, ID_polja, lat, lng: enter image description here

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]
4
  • use DISTINCT with sql query Commented Mar 4, 2014 at 11:41
  • try DISTINCT keywords Commented Mar 4, 2014 at 11:41
  • how>.........please help me Commented Mar 4, 2014 at 11:43
  • dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html Commented Mar 4, 2014 at 11:44

6 Answers 6

3

Maybe GROUP and ORDER:

SELECT * FROM `koordinate` GROUP BY `ID_polja` ORDER BY `ID` ASC
Sign up to request clarification or add additional context in comments.

Comments

2
SELECT * FROM `koordinate` GROUP BY `ID_polja`

Comments

1
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.

1 Comment

INSTINCT? i have never seen this in a SQL!
1
SELECT * FROM koordinate GROUP BY ID_polja;

Comments

1

try this

 SELECT * FROM `koordinate` group by ID_polja;

Comments

1

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.