select * from tablename as t where(t.field1 like '%param1%' or 'param1' is null) or (t.field2 like '%param2%' or 'param2' is null) ...
tablename 为表名
field1、field2 ...为需要查询的字段名
param1、param2...为传入的参数