CommanderSpock
CommanderSpock

Reputation: 31

Query mysql - results unexpected

SELECT results.data_scrap AS data_badania,
  tests.data_test AS data_badania2,
  results.words_count_out_a AS liczba_slow,
  results.position AS pozycja
FROM results,
  tests,
  keywords
WHERE results.keyword=test
AND tests.id=1
ORDER BY results.position 

I got this query, I don`t know why, but in my results one row is repeated several times.

SELECT *
FROM results,
  tests,
  keywords
WHERE results.keyword=test
AND tests.id=1
ORDER BY results.position

The result is 1.1.1.1.1.2.2.2.2.2.3.3.3.3.3 instead of 1.2.3.

Upvotes: 1

Views: 51

Answers (1)

Austin Schaefer
Austin Schaefer

Reputation: 696

Try this:

SELECT DISTINCT *
FROM results,
     tests,
     keywords
WHERE results.keyword=test
AND tests.id=1
ORDER BY results.position

Alternatively, try this:

SELECT *
FROM results,
     tests,
     keywords
WHERE results.keyword=test
AND tests.id=1
GROUP BY results.position

Upvotes: 2

Related Questions