How can i do, that if my field in db is less then 10 symbols, search via non strong like, but if more than 10, than with %% options?
So how to check field length?
My code in ruby is such:
@search = CrossList.find(:all, :conditions => ['cross_value like ? ', oem_condition])
But how to do something like:
@search = CrossList.find(:all, :conditions => ['length(cross_value) < 10 and cross_value like ? ', oem_condition])
else
@search = CrossList.find(:all, :conditions => ['length(cross_value) >= 10 and cross_value like %?% ', oem_condition])
Use two conditions, and
ORthem together:The
LENGTH()condition must be met by one of the two()groups, and whichever is met will also require that theLIKEcondition with which it isAND‘d will be applied.