Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    3

    Unanswered: Need help searching tables

    Hello everyone! I've been going crazy trying to figure out this problem. Okay so here it goes: I have an ASP page that has a simple search function that searches a field in a table in my database. Here is the SQL statement in that ASP file:

    SQL = "SELECT * FROM products INNER JOIN product_properties ON products.product_id = product_properties.product_id WHERE products.main_category LIKE '%" & Keyword & "%'"

    At first, my problem was that the data was not being pulled from these two tables. But since I used the INNER JOIN, it now pulls it out and that's not a problem anymore. The real problem is that my search function isn't working. When I search, I only get like 4 records even though there are really 25 records for the search keyword "Stapler." If anyone can see what I'm doing wrong, I would really appreciate it if you can point it out. If you need more information, ask me to post it. Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Is your database doing case-sensitive compares? In other words, does "Stapler" equal "stapler" ? Be careful before you answer, because some database engines only do one sort order, some do orders by table, some do orders by column.

    -PatP

  3. #3
    Join Date
    Apr 2004
    Posts
    3
    Well I can only answer you with I don't know because that's the truth. I can tell you I'm using Acess as my database but as far telling you how its sorting it, I can't. I thought you could specify in the SQL statement how to search a keyword.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Ah ha! MS-Access (actually Jet, the MDB database engine) would require something more like:
    Code:
    sql = "SELECT * FROM products INNER JOIN product_properties "
    & "ON products.product_id = product_properties.product_id "
    & "WHERE products.main_category LIKE ""*" & Keyword & "*"""
    Be sure that you at least try using this verbatim before you start to play with it.

    -PatP

Posting Permissions

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