如何从数据库中选择特定数据并在网格中显示 [英] how to select perticular data from database and display in grid

查看:74
本文介绍了如何从数据库中选择特定数据并在网格中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DROP PROCEDURE IF EXISTS hms.Select_Parameter1;
CREATE PROCEDURE hms.`Select_Parameter1`(_Branch_Id     int,
                                         _Tenant_Id     int,
                                         _disease_Id    int,_ParameterId int)
BEGIN
      IF EXISTS
            (SELECT  b.Target_Value
               FROM patient_progress_tracking_header b
              WHERE b.DiseaseId = _disease_Id)
      THEN
         SELECT a.ParameterName,
                b.Target_Value,
                b.Measurement_Frequency,
                date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
                c.Result,
                 date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
                c.Remarks,
                date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
                b.ParameterId 
                
           FROM patient_progress_tracking_header b
                RIGHT JOIN Disease_parameter a
                   ON a.ParameterId = b.ParameterId
                INNER JOIN patient_progress_tracking_details c
                   ON b.ParameterId = c.ParameterId
          WHERE     b.Branch_Id = _Branch_Id
                AND b.Tenant_Id = _Tenant_Id
                AND b.DiseaseId = _disease_Id;
      ELSE
         SELECT a.ParameterName,
                a.Target_Value,
                b.Measurement_Frequency,
                date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
                c.Result,
                 date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
                c.Remarks,
                date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
                a.ParameterId
                
           FROM patient_progress_tracking_header b
                RIGHT JOIN Disease_parameter a
                   ON  b.ParameterId =a.ParameterId
                INNER JOIN patient_progress_tracking_header b
                   ON b.ParameterId = c.ParameterId
          WHERE     a.Branch_Id = _Branch_Id
                AND a.Tenant_Id = _Tenant_Id
                AND a.DiseaseId = _disease_Id
                AND a.ParameterId=_ParameterId;
      END IF;
   END;



这是我的sp。问题是其他部分没有执行...因为 ON b.ParameterId = c.ParameterId 表中没有这个条件..我希望当patient_progress_tracking_header中没有数据时b table和patient_progress_tracking_header b表,目标值和参数名称应来自Disease_parameter并显示在grid ..


this is my sp. Problem is else part is not executing ...because ON b.ParameterId = c.ParameterId this condition is not present in table..i want when there is no data in patient_progress_tracking_header b table and patient_progress_tracking_header b table ,Target value and parameter name should come from Disease_parameter and displayed in grid..

推荐答案





在你的else部分查询,其中是别名表C,c未声明。



Hi,

In your else part query where is alias table C, c is not declared.

SELECT a.ParameterName,
                a.Target_Value,
                b.Measurement_Frequency,
                date_format(c.Last_Date,"%y/%d/%m") as 'Last_Date',
                c.Result,
                 date_format(c.Next_Due_Date,"%y/%d/%m") as 'Next_Due_Date',
                c.Remarks,
                date_format(c.Current_Test_Date,"%y/%d/%m") as 'Current_Test_Date',
                a.ParameterId
                
           FROM patient_progress_tracking_header b
                RIGHT JOIN Disease_parameter a
                   ON  b.ParameterId =a.ParameterId
                INNER JOIN patient_progress_tracking_header b
                   ON b.ParameterId = c.ParameterId
          WHERE     a.Branch_Id = _Branch_Id
                AND a.Tenant_Id = _Tenant_Id
                AND a.DiseaseId = _disease_Id
                AND a.ParameterId=_ParameterId;


这篇关于如何从数据库中选择特定数据并在网格中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆