Text search...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter the Swede

    #1

    Text search...

    Best groupmembers,

    I'm new to MySQL and I'm not quite sure what I'm doing wrong. I have a
    table "general" that contains some columns. I want to do a search thru
    it and find posts that have a specific word in the title and text
    column.

    This is the query that I use that creates an error.

    $Query = "SELECT * FROM general WHERE MATCH(title,tex t)
    AGAINST('$searc hstring')";

    This is just modified SQL from the manual on www.mysql.com

    Any hints?

    Cheers, Peter
  • Michael J. Astrauskas

    #2
    Re: Text search...

    Peter the Swede wrote:
    [color=blue]
    > Best groupmembers,
    >
    > I'm new to MySQL and I'm not quite sure what I'm doing wrong. I have a
    > table "general" that contains some columns. I want to do a search thru
    > it and find posts that have a specific word in the title and text
    > column.
    >
    > This is the query that I use that creates an error.
    >
    > $Query = "SELECT * FROM general WHERE MATCH(title,tex t)
    > AGAINST('$searc hstring')";
    >
    > This is just modified SQL from the manual on www.mysql.com[/color]

    Hello Peter,
    I'm not very familiar with the MATCH AGAIN clause (I know it but have
    not used it), but I did find the following on page 129 of the MySQL manual:

    To use MATCH ... AGAINST (... IN BOOLEAN MODE) with your tables, you
    need to rebuild them with REPAIR TABLE table_name USE_FRM.

    I know you can use the following instead:

    $Query = "SELECT * FROM general WHERE title LIKE '%$searchstring %' OR
    text LIKE '%$searchstring %'"

    Of course, the above won't give scores. It will either find something or
    it won't.

    You might find some configuration insight in section 13.7 of the manual,
    as well (page 613).

    --
    - Michael J. Astrauskas

    Comment

    • Michael J. Astrauskas

      #3
      Re: Text search...

      Peter the Swede wrote:
      [color=blue]
      > Best groupmembers,
      >
      > I'm new to MySQL and I'm not quite sure what I'm doing wrong. I have a
      > table "general" that contains some columns. I want to do a search thru
      > it and find posts that have a specific word in the title and text
      > column.
      >
      > This is the query that I use that creates an error.
      >
      > $Query = "SELECT * FROM general WHERE MATCH(title,tex t)
      > AGAINST('$searc hstring')";
      >
      > This is just modified SQL from the manual on www.mysql.com[/color]

      Hello Peter,
      I'm not very familiar with the MATCH AGAIN clause (I know it but have
      not used it), but I did find the following on page 129 of the MySQL manual:

      To use MATCH ... AGAINST (... IN BOOLEAN MODE) with your tables, you
      need to rebuild them with REPAIR TABLE table_name USE_FRM.

      I know you can use the following instead:

      $Query = "SELECT * FROM general WHERE title LIKE '%$searchstring %' OR
      text LIKE '%$searchstring %'"

      Of course, the above won't give scores. It will either find something or
      it won't.

      You might find some configuration insight in section 13.7 of the manual,
      as well (page 613).

      --
      - Michael J. Astrauskas

      Comment

      Working...