请查看以下代码并帮我修复错误。
当我试图执行它时,我只得到以ENTBI-Q开头的记录。但是下面写的两个条件(任务%,INC%)没有被执行。
我想要以task,incident和entbi-q开头的记录。
请注意,任务和事件是一列的字段值,而entbi-q是另一列的字段值。
SELECT
S1."NAME" AS "NAME",
S1."SYS_ID" AS "SYSID",
T2."ASSIGNMENT_GROUP" AS "ASSIGNMENTGROUP",
T2."NUMBER_" AS "NUMBER",
T2."CLOSED_AT" AS "CLOSEDAT",
T2."OPENED_AT" AS "OPENEDAT"
FROM
"IOD"."SYS_USER_GROUP" S1,
"IOD"."TASK" T2
WHERE
(S1."SYS_ID"=T2."ASSIGNMENT_GROUP")
AND S1."NAME" LIKE 'ENTBI-Q%'
AND T2."NUMBER" LIKE 'TASK%'
AND T2."NUMBER" LIKE 'INC%'
答案 0 :(得分:5)
AND T2."NUMBER" LIKE 'TASK%'
AND T2."NUMBER" LIKE 'INC%'
这永远不会成真。如果字符串以TASK
开头,则无法以INC
开头。您可能希望OR
这两个条件:
AND (T2."NUMBER" LIKE 'TASK%'
OR T2."NUMBER" LIKE 'INC%')