select col1, col2, col3 from tab_name where (? is null or foo = ?) and (? is null or bar = ?) and (? is null or baz = ?)