SQL Select statement as a keyword search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adelemb
    New Member
    • Feb 2008
    • 6

    SQL Select statement as a keyword search

    Hi,

    I'm trying to make a SQL statement work and am getting quite mixed up with it, I hope someone can help!

    I have a form with a textbox named "keyword". I want the user to enter a keyword and then a search occurs through the table to find that keyword. The results should then be displayed on the next page. I have the keyword parameter appearing in the page URL e.g. www.xxxxxx.com/page.htm?keywor d=help

    My problem (I think) is the way I am calling the keyword variable in the SQL statement? I have tried countless variations but I either get red error messages or a blank page.

    Code:
    var keyword = request.keyword;  
    
    var sql = 'SELECT threadID, forumID, masterID, subject, message, datePosted FROM threads WHERE UPPER(message) LIKE UPPER('%' + keyword + '%')'  
    
    var result = database.execute(sql);  
    
    while(result) { 	
    
    nextCol(result[3])
    nextCol(result[5])
    nextCol(result[1])
    nextCol(result[2])
    nextRow()
    
    result = database.nextRow(); } 
    
    update();
    Can anyone help? I'm sure it's something obvious but am pulling my hair out trying to fix this!! (and baldness would really not suit me)
    Let me know if more info is needed, thank you!!
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Please print the query at run time in your screen and try to execute taht query in sql plus or TOAD and check if the data really exist.

    Please post the run time query here for reference.

    Comment

    Working...