How to select records where one column does not contain another

Last Post 13 Dec 2011 12:27 PM by Kingfish. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Kingfish
New Member
New Member

--
13 Dec 2011 11:26 AM
I have a 'person' table with an accountname column and a firstname column. I need to find all person records where accountname does not contain firstname. I cannot use not equal since some part of the account name will contain the firstname. For example: accountname ABC, Inc and firstname ABC would not be returned in the results but ABC, Inc. and Bob would. Any help is appreciated.
gunneyk
New Member
New Member

--
13 Dec 2011 12:18 PM
I am not 100% sure what you are asking but I think a LIKE will work for you.

SELECT * FROM [Person] WHERE AccountName NOT LIKE '%' + Firstname + '%'
Kingfish
New Member
New Member

--
13 Dec 2011 12:27 PM
Thanks...that was it. Feel stupid....
You are not authorized to post a reply.

Acceptable Use Policy