var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: LIKE problem
I'm trying to filter contacts table. User can Filter by any combination of FirstName, LastName, Address and Phone number.
SELECT First_name, Last_name, Phone_number, Address
WHERE First_name LIKE @first + '%'
AND Last_name LIKE @last + '%'
AND Phone_number LIKE @phone + '%'
AND Address LIKE @address + '%'
Above example doesn't show if some fields of contact is NULL. It works okay if empty but doesn't work on NULL.
For instance let's say above data is in DB. If use search for @first = AB and all the other parameters empty. It doesn't show above data since phone_number is not empty but NULL
First_name -- Last_name -- Phone_number -- Address
AB CD NULL ABC
Is there any recommendation?
the best solution is
1) test @phone
2) if it's empty, do not include the phone condition in the WHERE clause
I solved to issue by using ISNULL
But yours make more sense to me. I will change it now. Thank you so much. Glad I asked.
ISNULL(first_name, '') like @first + '%'