MySQL Stored Procedure with Multiple Select statements From Different Tables

后端 未结 4 515
萌比男神i
萌比男神i 2021-01-26 05:33

I\'m trying to do multiple selects from different tables in a mysql stored procedure as follows

DELIMITER //  
CREATE PROCEDURE `NovemberSummary`(IN `branch` VA         


        
4条回答
  •  一向
    一向 (楼主)
    2021-01-26 05:42

    Using Multiple Select Statement in Stored Procedures

    Try with the below query.

        select distinct ProdSubCategory, NULL,NULL
    from Table1
    inner join Table2 on ID_FK= ID_PK
    where Table2.Type=@chvType and Table1.ProdCategory=@chvProdSubCategory
    
    UNION ALL
    
    select NULL, Brand,NULL
    from Table1
    inner join Table2 on ID_FK= ID_PK
    where Table2.Type=@chvType and Table1.ProdCategory=@chvProdSubCategory
    
    UNION ALL
    select NULL, Price,NULL
    from Table1
    inner join Table2 on ID_FK= ID_PK
    where Table2.Type=@chvType and Table1.ProdCategory=@chvProdSubCategor
    

提交回复
热议问题