Reputation: 319
How do I check if a column has all the rows the same value?
I don't think this will work.
SELECT column FROM table WHERE value = 1
I want to make, by time each row will turn from 0 to 1 till every row has value 1, if all the values are 1 to turn all in 0
id value
1 1
2 1
3 1
4 1
5 1
6 1
7 1
Upvotes: 6
Views: 12605
Reputation: 979
Try this query :-
select count(value) from table where value =0;
if rows return count
is zero
that means there are no zeroes in that column.
Upvotes: 9
Reputation: 6661
Use count
SELECT count(value) as total FROM table
if total > 1 than more than on value
Upvotes: 2
Reputation: 172608
You can try to use distinct
select count(distinct column) FROM table
If the result is 1 then it means there is only same value present in the column else there are different values present in your column.
Upvotes: 12