-1

電子患者記録システムの の「 」列にsql保存されている、 の数千の患者記録から情報を取得しようとしています。commentsProgress Note table

要求の機密性と患者を特定できる情報の問題により、comments患者データの侵害となる追加の不要な情報を引き出すことなく、この「 」列から必要なデータのみを引き出したいと考えています。

comments」列 (フリー テキスト列) には、各患者がコンサルタントに会ったときに書かれたテキストが多数含まれていdiagnosisます。medicationgeneral notes

私の研究では、この「コメント」列に次の単語が含まれている患者のみを抽出する必要があります。

ミルタザピン、統合失調症および双極性障害

これらの 3 つの単語は、研究目的で有効であると見なされるために、患者ごとの各コメント欄に存在する必要があります。したがって、患者のコメントの 1 つに 3 つのキーワードのうち 2 つが含まれている場合、私はそれを使用しません (また、不要な抽出と見なされるため、見たくありません) - 私は見たいだけです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 に答える