如何在oracle sql中替换开始和结束引用

时间:2016-06-18 21:16:19

标签: sql oracle

我有一个oracle sql,我想用in子句获取一些数据。但我在语法的开头和结尾引用有错误。我不知道如何删除它。我用Google搜索并尝试更换,修剪但没有运气。有人可以帮我这个吗?以下是我的查询::

我当前提出错误的查询>>>

    SELECT CARE_TOPIC_ID, CARE_TOPIC_NAME, CREATED_BY, HISTORY_OF_ILLNESS, ASSESSMENT, PLAN FROM CARE_TOPIC_TEMPLATES 
  WHERE CARE_TOPIC_ID in ('1,2,3') ; 

所需的查询应为>>

    SELECT CARE_TOPIC_ID, CARE_TOPIC_NAME, CREATED_BY, HISTORY_OF_ILLNESS, ASSESSMENT, PLAN FROM CARE_TOPIC_TEMPLATES 
  WHERE CARE_TOPIC_ID in (1,2,3) ; 

1 个答案:

答案 0 :(得分:0)

如果CARE_TOPIC_ID的数据类型是文本,则正确用法为:

  SELECT CARE_TOPIC_ID, CARE_TOPIC_NAME, CREATED_BY, HISTORY_OF_ILLNESS, ASSESSMENT, PLAN FROM CARE_TOPIC_TEMPLATES WHERE CARE_TOPIC_ID in ('1','2','3') ; 

否则如果是数字,则:

  SELECT CARE_TOPIC_ID, CARE_TOPIC_NAME, CREATED_BY, HISTORY_OF_ILLNESS, ASSESSMENT, PLAN FROM CARE_TOPIC_TEMPLATES WHERE CARE_TOPIC_ID in (1,2,3) ;