Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-22-2012, 01:50 PM   PM User | #1
cancer10
Regular Coder

 
Join Date: Jun 2006
Location: India
Posts: 799
Thanks: 211
Thanked 2 Times in 2 Posts
cancer10 can only hope to improve
Question Question about a user's login table

HI

Here is a telephonic question that i was recently asked

When designing a table where the user's username and password are saved, apart from adding indexes to the columns, is there anything else that you should do so that when running a query like:

SELECT username FROM users WHERE username="abc" AND password="xyz"

the query does not scan the entire table?




Does anyone here knows the answer and tell me what is it?

Thanks
cancer10 is offline   Reply With Quote
Old 10-22-2012, 03:47 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 362 Times in 361 Posts
sunfighter is on a distinguished road
I believe a query always scans the entire table. How else would it find multiple listings?
If you don't care about multiple listings you could use LIMIT 1 to stop the search.
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:47 AM.


Advertisement
Log in to turn off these ads.