View Single Post

   
  #1 (permalink)  
Old 03-01-2008, 02:26 PM
manning_news@hotmail.com
 
Posts: n/a
Default Need SELECT ... LIKE help, please

I've got the following SELECT statement in a stored procedure:

SELECT FirstName, LastName, BusinessName, MailingAddress1
FROM tblAddresses
WHERE FirstName LIKE '%' + ISNULL(@FirstName, '') + '%' AND
LastName LIKE '%' + ISNULL(@LastName, '') + '%'

If I input "tom" for @FirstName then it returns rows with "tom"
somewhere in the first name but that row must have a last name too in
order to be returned. How do I change this to return both types of
rows: one with "tom" as a firstname and with a lastname and one with
"tom" as first name but no last name?

Thanks for any help or advice.

Reply With Quote