我有這種情況: 名爲table 1
的表,其列名爲groups
。 我該列有一個範圍,我需要拆分並與可變myGroup
是否有可能分裂一個SQL單元格,然後比較字符串?
事後比較組目前我這樣做的:
myGroup = 32
trueGroup = false
sql = "select * from table1 where groups like '%" & myGroup & "%'"
set rs = conn.execute(sql)
if not rs.eof
do until rs.eof
title = rs("title")
groups = rs("groups")
groupsSplitted = split(groups, ",")
for i = lbound(groupsSplitted) to ubound(groupsSplitted)
if cint(myGroup) = cint(groupsSplitted(i)) then
trueGroup = true
end if
next
if trueGroup
response.write(title)
end if
next
end if
是否有可能做的所有的SQL行? :)
一個設計合理的表格結構可以將這些組分成一個單獨的表格,每個記錄一個組,這樣做完全沒有必要進行這種分割。換句話說:修復你的表格結構,這個問題將消失:http://en.wikipedia.org/wiki/Database_normalization –