How can I test for null and not null at the same time in sql?
问题 I have this sql: select * from employees where lastname like '%smith%' and firstname like '%bob%' and middle like '%%' The problem is the values of the name, particularly the middle name, can be null. So the statement above will find: smith, bob mike but will not find smith, bob because Bob's middle name is null (he has no middle name.) I have this which works but I thought there was a better way and wanted input: select * from employees where lastname like '%smith%' and firstname like '%bob%