我在mysql數據庫的列letters
中有以下數據。我將它們保存在varchar
中:數據庫中的字符串數組。匹配並返回值
letters
["a","b"]
["a","b","d"]
["a","d"]
["d","c","e"]
["e","c","f"]
["c","f"]
["f","e"]
我想匹配一些元素。當我有params[:lttrs]
爲"a"
,我想回:
["a","b"]
["a","b","d"]
["a","d"]
當我有params[:lttrs]
爲"c,e"
,我想回:
["d","c","e"]
["e","c","f"]
我嘗試檢索所有行,然後相互匹配其中有include?('a')
,但以此,我一次只能做一個元素。這是方法嗎?
當'params [:lttrs]'是「a,c,e」還是「b,d,e,f」會發生什麼? – 2013-05-08 07:12:16