If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Need help searching tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-04, 16:05
ProEdge ProEdge is offline
Registered User
 
Join Date: Apr 2004
Posts: 3
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
Reply With Quote
  #2 (permalink)  
Old 04-13-04, 22:02
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
  #3 (permalink)  
Old 04-14-04, 12:07
ProEdge ProEdge is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 04-14-04, 16:26
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On