Click here to Skip to main content
15,923,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All

I have a Table in which there is a column "Usertype".
In usertype column two values are there ("FREE","free").

I want to separate those records based on usertype.

like
(1) "select from userinfo where usertype='FREE'"
(2) "select from userinfo where usertype='free'"


But in both case all the records are coming.

Can anybody please help to find out what exact query should be to separate those records.

I will be thankful if I will get the solution.

Regards
Asutosha Sarangi
Posted

You have to enable case sensitivity for your column like this on SQL Server:

SQL
ALTER TABLE userinfo
    ALTER COLUMN UserType VARCHAR(10) 
    COLLATE SQL_Latin1_General_CP1_CS_AS
 
Share this answer
 
v2
Comments
Thiagarajan Duraisamy 14-Sep-11 2:39am    
he is asking for the query na,
some time the query can be used to generate bost results in that case using collate will not help na.
its a suggestion tat, using binary check sum is sufficient for query, than modifing the table.
Simon Bang Terkildsen 14-Sep-11 2:44am    
Mehdi is posting a good option to the OP, might not be exactly what the OP is after, but it is an option. Just like your suggestion which might actually be less usefull as I don't believe MySQL has binary_checksum
Thiagarajan Duraisamy 14-Sep-11 2:53am    
thanks yar.
Thiagarajan Duraisamy 14-Sep-11 2:59am    
but u can use 'binary' to check tat na
 
Share this answer
 
v2
Comments
Thiagarajan Duraisamy 14-Sep-11 2:39am    
he is asking for the query na,
some time the query can be used to generate bost results in that case using collate will not help na.
its a suggestion tat, using binary check sum is sufficient for query, than modifing the table.
Prerak Patel 14-Sep-11 2:53am    
It's not about changing table at all.
Link show that COLLATE can be used in query too.
select * from t1 where CONVERT(a USING latin1) COLLATE latin1_general_cs ='Darren'
SQL
select * from <table name=""> where (binary_checksum(Usertype) = binary_checksum('free'))</table>


hope this helps.
 
Share this answer
 
v2
Another option:
LIKE is case sensitive so you can use

According to
http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like[^] LIKE is case sensitive when one of the operands is a binary string.

SQL
select from userinfo where usertype LIKE BINARY 'FREE'

SQL
select from userinfo where usertype LIKE BINARY 'free'
 
Share this answer
 
v2
Comments
Simon Bang Terkildsen 14-Sep-11 2:54am    
very true, I read the documentation wrong, I've updated the answer.
Thiagarajan Duraisamy 14-Sep-11 23:51pm    
ya now its fine

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900