Searching a field with comma separated string...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jimmyTcobra
    New Member
    • Feb 2010
    • 1

    Searching a field with comma separated string...

    .. Hi peeps. I have search for guidance but google isnt doing its job like it used to and would like to reach out to yall for help.

    My problem is below and i am doing this in access 2007.

    I have a table Hobbies:

    Hobbies
    |names||city||D OB||keywords||

    Records for example, would be like:

    |James Ross||London||1 2/12/85||cricket, snooker, electornics, building||
    |David Magambo||Manche ster||01/09/87||gaming, biking, poker||
    |Hans Gruber||Berlin| |01/01/73||smoking, programming, gaming, tennis||

    I want to be able to search the comma separated string for words. for example if i were to search for the people with the keywords "gaming" it would bring up David and Hans recrods, or if i were to search for keywords "cricket" or "tennis" it would bring up James and Hans records..

    Im guessing it would be an sql query? and it might be trivial but i have no idea how to go about this and would really appreciate the help.

    Thank, Jimmy.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Correct, you need the "LIKE" comparison with the "*" wold character in the WHERE clause like:
    Code:
    select * from tblHobbies where keywords like '*tennis*'
    Nic;o)

    Comment

    Working...