If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > The same data in column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-29-12, 09:07
duf duf is offline
Registered User
 
Join Date: Jan 2012
Posts: 89
The same data in column

Hi.
Is there a query to check if all data in one column are the same? Thanks.
Reply With Quote
  #2 (permalink)  
Old 06-29-12, 10:47
kordirko kordirko is offline
Registered User
 
Join Date: Jan 2012
Posts: 84
Just count distinct values in a column, like this.
Code:
SELECT CASE WHEN count( DISTINCT column ) < 2 
            THEN 'SAME' 
            ELSE 'NOT SAME' 
       END result 
FROM table;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On