- (let ((qs (format nil "select ~A~{~:@(~A~)~^,~} from ~:@(~A~)"
- (if distinct "distinct " "")
- fields table)))
- (when where-name
- (setq qs (concatenate 'string qs
- (format nil
- (if (stringp where-value)
- (if like
- " where ~A like '%~A%'"
- " where ~A='~A'")
- " where ~A=~A")
- where-name where-value))))
- (when srl
- (setq qs (concatenate 'string qs (format nil " and ~:@(~A~) <= ~D"
- lrlname srl))))
- (when order
- (setq qs (concatenate 'string qs
- (format nil " order by ~{~:@(~A~) ~(~A~)~^,~}"
- (flatten
- (loop for o in order collect
- (if (atom o)
- (list o 'asc)
- (list (car o) (cdr o)))))))))
- (when single
- (setq qs (concatenate 'string qs " limit 1")))
- qs))
+ (concatenate
+ 'string
+ (format nil "select ~A~{~:@(~A~)~^,~} from ~:@(~A~)"
+ (if distinct "distinct " "") fields table)
+ (if where-name
+ (format nil
+ (if (stringp where-value)
+ (if like
+ " where ~A like '%~A%'"
+ " where ~A='~A'")
+ " where ~A=~A")
+ where-name where-value)
+ "")
+ (if srl (format nil " and ~:@(~A~) <= ~D" lrlname srl) "")
+ (if order
+ (format nil " order by ~{~:@(~A~) ~(~A~)~^,~}"
+ (flatten (loop for o in order collect
+ (if (atom o)
+ (list o 'asc)
+ (list (car o) (cdr o))))))
+ "")
+ (if single " limit 1" "")))