1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Need exact word match for MySql db

Discussion in 'Software Development' started by HowdeeDoodee, Feb 17, 2005.

Thread Status:
Not open for further replies.
Advertisement
  1. HowdeeDoodee

    HowdeeDoodee Thread Starter

    Joined:
    Aug 26, 2004
    Messages:
    614
    I am looking for a way to get exact word matches using php to access a MySql db. If I use the %LIKE% operator I get matches but some of the matches are wildcards. My fields are text with phrases and sentences so I have not been able to use the equal sign in the SELECT statement. Does anyone know how I can get exact matches using the select statement?
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Are the criteria based on an input form from a user? If it is you can make the text box a variable in your SQL statement using the = sign.
     
  3. HowdeeDoodee

    HowdeeDoodee Thread Starter

    Joined:
    Aug 26, 2004
    Messages:
    614
    Yes, the input is from a user via text boxes and drop down menus. Here is the select statement.

    $query = "SELECT * FROM `View1` WHERE `Topic` LIKE '%$SeeAlso%'";

    Here is an example of a record.

    Wood | Sanding wood smooth requires sandpaper | Reference 121

    When a user types in the word "sand" using the wild card % operator this record will be found. However, I want only the records containing "sand" pulled up. I do not want records with "sanding", "sandpaper", or any words with the letters "sand" within a word pulled up.

    If I replace the LIKE operator with an equal sign won't the whole field in the database have to actually equal what the user types in, in order for a record to be pulled up? In other words, if a record contains the sentence "Sand castles are on the beach", won't that record be ignored if I use the = sign instead of the LIKE operator? I have tried using the = sign without success.
     
  4. HowdeeDoodee

    HowdeeDoodee Thread Starter

    Joined:
    Aug 26, 2004
    Messages:
    614
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/331573

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice