【问题标题】:Getting all the records from Patient entity with primary insurance of the patient can be 'P' that is primary从具有患者主要保险的患者实体获取所有记录可以是“P”,即主要
【发布时间】:2013-05-07 05:00:27
【问题描述】:

我想要JQPL 语法中的以下 SQL 查询:

select P.*,PIN.INSURANCE_COMPANY_ID
from PATIENT_INSURANCE PIN 
right join PATIENT P ON (PIN.Patient_ID = P.ID 
and PIN.INSURANCE_TYPE = 'P' AND PIN.STATUS = 'A')
where P.STATUS = 'A'

请帮忙。

【问题讨论】:

  • 您的问题含糊不清,与您粘贴的示例没有明确的联系。请提供清晰的背景,说明您要做什么、问题是什么以及您正在寻求什么帮助。

标签: mysql jpql


【解决方案1】:

试试这个:

select 
  p.id,
  p.lastName,
  p.firstName,
  p.middleName,
  p.dob,
  p.sex,
  p.ssn,
  p.phone,
  p.status,
  pi.insuranceCompanyId ,
  IF(pi.insuranceType ='P' , 'is P', 'is not P')
from 
  PatientInsurance pi 
right join Patient p 
  on pi.patientID = p.id

或者,如果您想要所有具有 pi.insuranceType ='P' 的记录,您可以附加到查询中: WHERE pi.insuranceType ='P'

【讨论】:

  • 我有 PATIENT TABLE 和 PATIENT_INSURANCE TABLE。
猜你喜欢
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多