Ok this is a bit complex
I currently have a search function that allows customers to search records based on 1 or more states.
they can enter multiple states and this function will search the post to match the post that matches any one of those states.
With this the post can only have 1 state.
I am tring to expand and allow each post to have multiple states. but for this to happen i need to figure out how to match any one of the seached states to any one of the posted states.
In this example type = "dest"
and states = "mo, ks, ar, ok"
def PrepareSearch.states(type, states)
states = states.split(",")
st = ""
states.each {|s| st += "'#{s}'," }
st = st[0..-2]
"#{type}_state IN (#{st})"
end
It would match a post that has any one of those states in dest_state and only has 1 of them in it
I need this to be expanded and match something like this:
dest_state = "mo, ks, ok, ar"
states = "ks, ne, co"
I need that to match because ks
is in both
But i also need it to work if it only has one state in the dest_state
as well
my database has 100k + records that this will be searching thru.
dest_state
is a stored field in the record in the database