Py学习  »  DATABASE

如何在MySQL中使用多个代码得到like语句的结果?

Shahab Haidar • 6 年前 • 2033 次点击  

enter image description here

我写了下面的查询得到上传结果。

set @v_stk_code = '50400'; -- 2753,8601
set @v_date = '0619';
set @sas = (Select Count(file_name) from ims_data.batchlog where file_name like concat('%',@v_stk_code ,'%',@v_date,'.txt','%') and file_name like 'SAS%' and upload_status = 'success');
set @product = (Select Count(file_name) from ims_data.batchlog where file_name like concat('%',@v_stk_code ,'%',@v_date,'.txt','%') and file_name like 'P%' and upload_status = 'success');
Select @v_stk_code,
    case 
        when @sas=0 and @product=0 then 'SAS and Product not Uploaded' 
        when @sas>0 and @product>0 then 'SAS and Product is Uploaded' 
        when @sas>0 and @product=0 then 'SAS uploaded but Product File Missing' 
        when @sas=0 and @product>0 then 'Product uploaded but SAS File Missing' 
    end as `Status`;

我得到了一个最粗代码的结果,但我想得到多个最粗的结果,这将在参数中提供。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/57056
文章 [ 1 ]  |  最新文章 6 年前