CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2008
    Posts
    20

    Regarding Sql Table...

    Hi Guys...CAn any1 help me on how to search a table...

    I have the fields... "ID (unique and primary key)" , " Movie name" , "Genre", "Rating".....

    Genre can be Comedy,Drama or Musical
    Rating CAN be R, G,PG

    Now i have an option in my app to search for movies with genre...that is i have 3 buttons.... Comedy, Drama ,Musical ..If i click any of the button i should get the related MOvies names.....

    Same for Rating also...

    My problem is if i have all of them in one table...if i have to search(say comedy movies...as they are not in order) i have to search for the entire table to get the answers......Can any1 tell me how to search witout searching the entire table.......

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Regarding Sql Table...

    So you want to find all occurrences of X in a table without searching the table for X?

    Can you ask your question in a way that makes sense?
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  3. #3
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Regarding Sql Table...

    Well, depending on what database you use, I'd say you should make an index on your Genre would properly be the best approach.
    It can speed up a query tremendously if made correct. In your example it looks like an index made on genre and id in that order, would be a good starting point.

    That way - if your index is made properly - then you'll not have to scan the entire table, but only go through the index and that is something the database should do for you...... depending on which database you use.
    Last edited by Alsvha; January 28th, 2009 at 02:50 AM. Reason: clarification

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured