1

我正在尝试运行一个基本的 sql 查询,其中搜索两个字符串之一:

  1. “每晚加班”
  2. “晚上的工作完成了”

我已经尝试了 where 命令,但我得到一个空的输出。这是有问题的部分:

      where execution_location = ('Nightly job up' or Nightly job 'finished');

请协助,提前谢谢。

4

5 回答 5

2

改用IN(...)

where execution_location in ('Nightly job up', 'Nightly job finished');

这是在一个子句中比较多个值的方法。

于 2013-10-06T08:32:38.367 回答
0

你的表情:

('Nightly job up' or 'Nightly job finished')

... 被评估为布尔表达式,结果为 0(或FALSE)(因为字符串评估为FALSE)。

因此,您的最后WHERE条款相当于:

... WHERE execution_location = 0

其他人已经提供了正确的语法:)

于 2013-10-06T08:49:06.607 回答
0

对于 MySQL 或 Transact-SQL,您的 where 字符串应该是:

WHERE (execution_location = 'Nightly job up' OR execution_location = 'Nightly job finished');
于 2013-10-06T08:33:15.580 回答
0

尝试:

WHERE execution_location IN ('Nightly job up, 'Nightly job finished');

或者,如果您想要找到以 Nightly 作业开头的每个字符串:

WHERE execution_location LIKE 'Nightly job%'
于 2013-10-06T08:37:51.533 回答
0

尝试

where execution_location in ('Nightly job up', 'Nightly job finished');
于 2013-10-06T08:38:19.857 回答