Hi All,

I have a list of entries from users and want mysql to only display entries that are unique.

The mysql statement is as follows

SELECT DISTINCT bids
FROM `tbl_bids`
ORDER BY `bids` ASC

On running the query it is still displaying items that appear more than once.

a table of data looks something like this

id user_id bids
1 1 0.1
2 1 0.2
3 1 0.3
4 2 0.1
5 2 0.2


Im wanting the output to show me, as seen in this table, the value of 0.3, but its listing everything.

Many thanks

Paul

Recommended Answers

All 2 Replies

That is not what distinct does. Distinct will show every value once. What you want is to output the bid that is only once in the table. Something like:

SELECT `bids` FROM `tbl_bids` GROUP BY `bids` HAVING COUNT(1) = 1 ORDER BY `bids` ASC

with your query, it's not just the 0.3 will be displayed, it will also display the 0.1 and 0.2

your recordset will look something like this

0.1
0.2
0.3

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.