Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    892
    Thanks
    301
    Thanked 2 Times in 2 Posts

    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

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,763
    Thanks
    23
    Thanked 548 Times in 547 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •