SELECT 语句中的多个条件? [英] Multiple conditions in a SELECT statement?

查看:50
本文介绍了SELECT 语句中的多个条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我没有使用 ABAP 的经验,我在这里猜测.

First off, I have no experience with ABAP, I'm operating on guesswork here.

我想向现有报告中的 SELECT 添加条件.现有代码如下所示:

I want to add a condition to a SELECT in an existing report. The existing code looks like this:

SELECT SINGLE *
  FROM EKPO
  WHERE EBELN = GT_MSEG-EBELN
  AND   EBELP = GT_MSEG-EBELP.

如果字段 F1 是某个值并且字段 F2 是 0,我想添加一个条件来排除记录(两个条件都必须为真以排除记录).我试过这个:

I want to add a condition to exclude the record if field F1 is a certain value and field F2 is 0 (both conditions must be true to exclude the record). I've tried this:

SELECT SINGLE *
  FROM EKPO
  WHERE EBELN = GT_MSEG-EBELN
  AND   EBELP = GT_MSEG-EBELP
  AND NOT (F1 = 'value' AND F2 = '0').

我收到语法错误:字段F1 = 'value' AND F2 = '0'"未知.它既不在指定的表之一中,也不由DATA"语句定义.

I get a syntax error: Field "F1 = 'value' AND F2 = '0'" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

字段 F1 和 F2 肯定存在于 EKPO 表中,我已经检查过.好像括号让编译器把内容看成字段名了,不知道为什么.

Fields F1 and F2 definitely exist in the EKPO table, I've checked. It seems that the brackets are making the compiler look at the contents as a field name, but I don't know why.

语法不正确,是我在某处遗漏了定义,还是两者都有?

Is the syntax incorrect, am I missing a definition somewhere, or both?

推荐答案

SELECT SINGLE *
  FROM EKPO
  WHERE EBELN = GT_MSEG-EBELN
  AND   EBELP = GT_MSEG-EBELP
  AND NOT ( F1 = 'value' AND F2 = '0' ).

这奏效了.基本上我只需要一个与括号相邻的空间.

This worked. Basically I just needed a space adjacent to the brackets.

这篇关于SELECT 语句中的多个条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆