Osa
Osa

Reputation: 1990

MYSQL select only 1 from 5 same values

I want to get one value out of 5 which are the same, lets say 5 records have the same value in some column.

How do I only get one out of them and not 5 ?

Upvotes: 4

Views: 10336

Answers (2)

favoretti
favoretti

Reputation: 30207

Add DISTINCT to your query:

SELECT DISTINCT field FROM table;

Upvotes: 13

Last1Here
Last1Here

Reputation: 1079

You could use

"SELECT * WHERE column = 'Term' ORDER BY column2 LIMIT 1"

and then a simple while loop to output the data

Upvotes: 0

Related Questions