October 23, 2008 at 1:20 am
Hi all,
I have a problem with the folllowing scenario that i have inserted the different password into my table but when i try to retrive the username and details for a particular user by pasword it's retriveing all three records instead of retriveing one record,Can any one help me on this
My Query
select * from login where pwd='Test123'
but when i try to retrive record with username i'm getting the correct o/p
select * from login where name='Martin' and pwd='Test123';
Following is the script,
--
create table login(name varchar(20),pwd varchar(20));
insert into login values('Martin','Test123');
insert into login values('Ricky','test123');
insert into login values('Watson','tesT123');
October 23, 2008 at 1:44 am
Chandru (10/23/2008)
Hi all,I have a problem with the folllowing scenario that i have inserted the different password into my table but when i try to retrive the username and details for a particular user by pasword it's retriveing all three records instead of retriveing one record,Can any one help me on this
My Query
select * from login where pwd='Test123'
but when i try to retrive record with username i'm getting the correct o/p
select * from login where name='Martin' and pwd='Test123';
Following is the script,
--
create table login(name varchar(20),pwd varchar(20));
insert into login values('Martin','Test123');
insert into login values('Ricky','test123');
insert into login values('Watson','tesT123');
For case sensitive search, use varbinary for ex:
select * from login where Convert(varbinary(8),pwd)= convert(varbinary(8),'Test123')
kshitij kumar
kshitij@krayknot.com
www.krayknot.com
October 23, 2008 at 2:00 am
That would mean your table have three different records with the same password. Depending on your requirement, you can setup USERNAME & PASSWORD as unique index keys.
-- CK
October 23, 2008 at 2:03 am
Thanks Mr.Krayknot it worked well..
Cheers.
October 23, 2008 at 2:32 am
Chandru (10/23/2008)
Thanks Mr.Krayknot it worked well..Cheers.
You are most welcome
kshitij kumar
kshitij@krayknot.com
www.krayknot.com
October 23, 2008 at 4:23 am
Chandru (10/23/2008)
create table login(name varchar(20),pwd varchar(20));insert into login values('Martin','Test123');
insert into login values('Ricky','test123');
insert into login values('Watson','tesT123');
If such situation is very common, I would suggest you to look in the collation settings.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy