2011-02-02 69 views
0

我需要在那裏 -current_queue不等於I01,並且不以F -prod_code有RSQL語句與幾個邏輯運算符

SQL = "SELECT " & Join(theseFields, ",") & " FROM [Acct Detail$] WHERE NOT (current_queue='I01' OR LEFT(current_queue,1)='F')" 

這對我的作品,除去I01開始啓動運行SQL查詢並以F開頭的隊列,但現在如何過濾不以R開頭的prod_code?

(這是ADODB,VBA,Excel和Microsoft.Jet.OLEDB.4.0)

回答

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但不current_queue I01的或有F開始

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')" 
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%' " 

如果這是你的訪問也必須檢查空,但它似乎並沒有與Excel中的一個問題。