我需要在哪里运行SQL查询 -current_queue不等于i01,不以F开头 -prod_code以R
开头SQL = "SELECT " & Join(theseFields, ",") & " FROM [Acct Detail$] WHERE NOT (current_queue='I01' OR LEFT(current_queue,1)='F')"
我可以从F开始删除i01和队列但现在如何过滤掉不以R开头的prod_code? p>
(这是ADODB,VBA,Excel,Microsoft.Jet.OLEDB.4.0)
答案 0 :(得分:1)
您可以使用Excel遇到区分大小写:
strSQL = "SELECT " & Join(theseFields, ",") & " FROM [Acct Detail$] " _
& "WHERE (Not (UCase(current_queue)='I01' " _
& "Or UCase(current_queue) Like 'F%')) " _
& " AND UCase(prod_code) Like 'R%' "
如果这是Access,你还需要检查Null,但它似乎不是Excel的问题。
答案 1 :(得分:0)
没关系,我决定坚持下去:
SQL = "SELECT " & Join(theseFields, ",") & " FROM [Acct Detail$] WHERE NOT (current_queue='I01' OR LEFT(current_queue,1)='F' OR LEFT(prod_code,1)='C' OR LEFT(prod_code,1)='P')"
仍然很好奇如何保持prod_code以R开头而不是i01的current_queue或以F开头
答案 2 :(得分:0)
为清晰起见,分成若干行,这些应该在一行
SQL = "SELECT " & Join(theseFields, ",") & " FROM [Acct Detail$]
WHERE LEFT(Prod_code,1) = 'R'
AND NOT (current_queue='I01' OR LEFT(current_queue,1)='F')"