Results 1 to 2 of 2

Thread: Search database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    Thailand
    Posts
    221

    Search database

    I design table which has column "keywords" for keep keywords seperated by comma (,). If user pass one keyword, how can I know that the keyword user select is exactly match with any keyword in field. I mean I just want SQL return only rows that user's keyword is exactly match with at least one keyword in "keywords" column.

    Ex.
    PK1 Data1 Data2 keywords
    1 1 1 apple, orange
    2 2 2 mange, orange
    3 3 3 mange, apple

    If user select keyword 'orange', SQL must return only row 1 and 2.
    Teeravee Sirinapasawasdee
    Gestalt IT Consulting Group
    Growth Your Business With e-Process

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    It's not good db design to have a field set up with multiple values like that. If you know there'll be a limited number of keywords, you could create separate columns for them in each row - keyword1, keyword2, etc.
    A better approach is to have separate rows, one keyword in each. As long as it's not a primary or unique field, you can have unlimited rows with the same keyword. The way you have it set up, I think you'd have to read the keyword field of each record and parse the resulting string for the desired keyword. This would be very inefficient and time consuming. But you could do it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width