
Hi. I made a query like this: (sql (:select '* :from 'kupci :where (:and (:like 'ime (concat-string "%" (parameter "ime") "%")) (:like 'prezime (concat-string "%" (parameter "prezime") "%")))) I want not to apply "like" if the field in database entry is empty (null). Is there some predefined way to do this or I have to program it myself ? (parameter is a hunchentoot parameter after submitting a form) Thanks

You could make that part of the query dynamic, like this: (sql (:select '* :from 'kupci :where (:and (:raw (if TEST (sql (:like 'ime (concat-string "%" (parameter "ime") "%"))) t)) (:raw (if TEST2 (sql (:like 'prezime (concat-string "%" (parameter "prezime") "%"))) t)))))
participants (2)
-
Haris
-
Marijn Haverbeke