带有WHERE CLAUSE的SELECT语句

时间:2014-02-27 13:50:25

标签: sql sql-server

请问我正在从选择查询中执行where子句,如下所示,有些人可以帮助我如何添加---- [CSI JOB] IS NULL OR> ='9/3/2010'AND在哪里查询。看看下面的查询

  SELECT * 
    FROM ABNESCCX
   WHERE SQL <> 'C' 
         AND [MYSQL] = 'B' OR [MYSQL] = 'D' 
         AND [CSI JOB] IS NULL 
         OR >= '9/3/2010' 
         AND [TNE TYPE] = 'Radio'
ORDER BY [TNE Completed];

3 个答案:

答案 0 :(得分:3)

你可能还想用括号写出[MYSQL]:

SELECT * 
FROM ABNESCCX
WHERE SQL <> 'C' 
 AND ([MYSQL] = 'B' OR [MYSQL] = 'D')
 AND ([CSI JOB] IS NULL OR [CSI JOB] >= '9/3/2010')
 AND [TNE TYPE] = 'Radio'
ORDER BY [TNE Completed];

答案 1 :(得分:2)

你必须写下这样的条件:

([CSI JOB] IS NULL OR [CSI JOB] >= '9/3/2010') AND

答案 2 :(得分:0)

SELECT *
FROM ABNESCCX
WHERE
    [SQL] != 'C'
    AND [MYSQL] IN ('B', 'D')
    AND ([CSI JOB] IS NULL OR [CSI JOB] >= '9/3/2010')
    AND [TNE TYPE] = 'Radio'
ORDER BY [TNE Completed];