Find records if one field contains another

  • I have two tables:  en_entity and cn_contact.  They have a common field that links them called enid.  If I want to find records where the lastname field in cn_contact is contained anywhere in the name field in en_entity how do I do that?

  • select e.enid, name, lastname

    from en_entity e

    inner join cn_contact c on c.enid = e.enid

    where e.name like '%'+c.lastname+'%'

     

    But you will have the problem of finding the name "Jo Greensleeves" in the lastname "Green".

  • Thanks Adrienne.  This will work just fine.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply