如果最大元素数量是可预测的,则可以使用此方法(请注意,您需要使用
UNIOn,而不是
UNIOn ALL)
Select DISTINCT thefield from thetable where Instr(thefield, ',') = 0UNIOn Select Distinct Mid(thefield, 1, Instr(thefield, ',')) from thetable Where len(thefield) - len(replace(thefield,',','')) = 1UNIOn Select Distinct Mid(thefield, Instr(thefield, ',')+1) from thetable Where len(thefield) - len(replace(thefield,',','')) = 1UNIOn Select Distinct Mid(thefield, Instr(thefield, ',')+1, Instr(Instr(thefield, ',')+1,thefield, ',')) from thetable Where len(thefield) - len(replace(thefield,',','')) = 2UNIOn Select Distinct Mid(thefield, Instr(Instr(thefield, ',')+1,thefield, ',')+1) from thetable Where len(thefield) - len(replace(thefield,',','')) = 2--.. and so on (repeat last two Selects as many time as you wish, increasing the where condition by one for each pair)
看起来有些笨拙,但应该可以完成工作。未经测试,因此,在值之前或之后可能会出现一个逗号逗号



