I want to do this
SELECT *
FROM sales_order_header
WHERE order_reference LIKE @order_reference + '%'
AND ((@booked_in IS NULL) OR ( booked_in = @booked_in))
AND ((@depot_assigned IS NULL) OR ( IF @depot_assigned = 'Y' depot_code <> ' ' ELSE depot_code = ' ') )
I’m sure you can all guess the OR ( IF @depot_assigned etc ) bit is failing.
How can i do something like this or do i have to do it as two separate select statements depending on the value of the @depot_assigned parameter.
1 Answer