-1

我正在尝试从我们的电子病历系统sql中存储在 ' comments' 列中的数千个患者记录中获取信息。Progress Note table

由于请求的敏感性和患者身份信息的问题,我只想从此“ comments”列中提取必要的数据,而不会提取可能违反患者数据的额外和不必要的信息。

在“ comments”列(这是一个自由文本列)中包含大量文本,这些文本是在每位患者看到他们的顾问时写的,diagnosis例如medicationgeneral notes

对于我的研究,我只需要提取那些“评论”列包含以下词语的患者:

米氮平、精神分裂症和双极

这三个词必须出现在每位患者的每个评论栏中,才能被认为对研究目的有效。所以,如果其中一个患者的评论包含三个关键词中的两个,我不会使用它(我不希望看到它,因为它会被视为不必要的提取)-我只想看到任何comments具有这 3 个关键词的“”。

有人可以帮忙吗??

4

1 回答 1

1

你可以使用这样的东西:

select *
from yourtable t1
where exists (select *
              from yourtable t2
              where comments like '%Mirtazapine%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%Shcizophrenia%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%bi-polar%'
                and t1.id = t2.id)

或者:

select *
from yourtable t1
where comments like '%Mirtazapine%'
  and exists (select *
              from yourtable t2
              where comments like '%Shcizophrenia%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%bi-polar%'
                and t1.id = t2.id)

SQL Fiddle with Demo

于 2012-09-17T11:37:25.167 回答