1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Tempermental Query?

Discussion in 'Databases' started by jayg5000, Dec 28, 2006.

  1. #1
    I have a query that is basically structured like this:

    $query1 = "SELECT MATCH () AGAINST ('$search')*4
                            + MATCH () AGAINST ('$search')
                            + MATCH () AGAINST ('$search')
                            AS Relevance
                            FROM items
    			WHERE ((MATCH () AGAINST ('$search') OR MATCH () AGAINST ('%$search%') OR MATCH () AGAINST ('$search'))) HAVING Relevance > 25 ORDER BY Relevance DESC";
    Code (markup):
    I would like to add a new field to the the query so that it can compair my search to one more field but every time i do, my query fails. I include that field in both the "SELECT MATCH" and "WHERE ((MATCH" so that both statements are identical but no go. The field i would like to add exists and resides in the "items" table so i don't see a problem there. Do the fields being queried need to be in a specific order or what? If i try to add or delete anything from this query it fails. Why?
     
    jayg5000, Dec 28, 2006 IP
  2. druidelder

    druidelder Peon

    Messages:
    285
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When you say it fails, do you mean that no results are returned when you know there should be some? Or do you get an error?
     
    druidelder, Dec 28, 2006 IP
  3. jayg5000

    jayg5000 Active Member

    Messages:
    223
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Yes, it says "Query Failed" and no results are displayed.
     
    jayg5000, Jan 2, 2007 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    did you do a var_dump of the SQL variable or echo $query1? Just display the exact query you will be running, and run it in your sql tool (NaviCat or phpMyAdmin, etc...) - They will give you fuller details of what's F'd up :)
     
    ccoonen, Jan 4, 2007 IP