Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Location
    1
    Posts
    11

    Unanswered: sql code like contains in ...

    Help me build an sql statement that selects fields if it contains a specific name, say joe. The field may have one name, or if multiple separated by commas (ann, joe, mike) or (joe, steve) or one (joe). I got the sql that gets all the fields that have (joe), but not if joe is with others. Any ideas...email michael.lynn@alc.com
    111

  2. #2
    Join Date
    Oct 2003
    Location
    BA, Argentina
    Posts
    39

    Re: sql code like contains in ...

    Originally posted by Michael Lynn
    Help me build an sql statement that selects fields if it contains a specific name, say joe. The field may have one name, or if multiple separated by commas (ann, joe, mike) or (joe, steve) or one (joe). I got the sql that gets all the fields that have (joe), but not if joe is with others. Any ideas...email michael.lynn@alc.com
    You didnt say in which database you are working. This works in SQL Server:
    SELECT * FROM TABLE1 WHERE PATINDEX("%,JOE,%",FirstName)>0 OR PATINDEX("%(JOE,%",FirstName)>0 OR PATINDEX("%,JOE)%",FirstName)>0 OR PATINDEX("%(JOE)%",FirstName)>0

    if youre not using SQL server, look in the help for a function which seaches a string within another.

Posting Permissions

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