ArticleNumber Company Storage
01-01227 12 2
01-01227 2 1 'filtered by company/storage in combination
01-01227 5 1
01-01227 12 1 'filtered by company/storage in combination
01-44444 5 4 'filtered by not match the articlenumber
欲進行過濾,從而含有行(company = 12
和storage = 1
)和(company = 2
和storage = 1
)將被過濾掉的結果集,並過濾上articlenr
。SQL查詢到兩個字段篩選組合
這就是我想到的,但肯定有一個更簡單的方法來做出該查詢?
SELECT * FROM MyTable
where
(Company=2 and Storage<>1 and ArticleNumber='01-01227')
or
(Company=12 and Storage<>1 and ArticleNumber='01-01227')
or
(Company<>2 and Company<>12 and ArticleNumber='01-01227')
結果後我:
ArticleNumber Company Storage
01-01227 12 2
01-01227 5 1
你說你想'過濾掉'company = 5和storage = 1,並且你正在返回查詢... – 2012-02-29 14:33:25
對不起,應該是公司2和存儲1!我現在改變了它。 – Stefan 2012-02-29 14:39:56
我剛剛提供了兩個答案 – 2012-02-29 14:40:33