I have a table like this:
column_a column_b
foo 1
bar 1
bar 2
baz 4
I'd like to have following result, containig all rows, that have a unique field value in column_b:
bar 2
baz 4
foo(0) and bar(1) both have the column_b value '1', so the '1' is not unique.
Is there a MySQL-Expression that filters all rows that have a unique column_b?
Maybe something like that:
select * from table where isunique(column_b)
In Addition: I do not need something like DISTINCT!
edit (solved):
Thanks to YaK and jcho360, this one is the solution:
select column_a, column_b from table group by column_b having count(column_b) = 1
OR
select column_a, column_b, COUNT(1) AS total from table group by column_b having total = 1
(thx to andrewtweber)