>select person_id from mytable where flag_1 OR flag_2 OR flag_3 ...but more than one of them....! >>
local lnFieldCount, i, lcColumnList local array laFields[1,16] use mytable in 0 lnFieldCount = afields(laFields, 'mytable') lcColumnList = '' for i = 1 to lnFieldCount if laFields[i,2] = 'L' lcColumnList = lcColumnList + 'iif('+laFields[i,1]+',1,0)+' endif endfor if len(lcColumnList) > 1 lcColumnList = left(lcColumnList,len(lcColumnList)-1)+' as flag_total' select person_id, &lcColumnList ; from mytable where flag_total > 1 else select person_id from mytable where .F. endif