If the user did not insert a value, say for nationalCode
, I assume the you pass NULL
(or an empty string?) as :nationalCode
and in this case your condition should be:
nationalCode = :nationalCode OR :nationalCode IS NULL
or:
nationalCode = :nationalCode OR :nationalCode = ''
So for all the columns the statement should be:
SELECT *
FROM insurance
WHERE (nationalCode = :nationalCode OR :nationalCode IS NULL)
AND (insuranceNumber = :insuranceNumber OR :insuranceNumber IS NULL)
AND (insuranceType = :insuranceType OR :insuranceType IS NULL);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…