mysql - Multiple IF Statements in SQL -


I am trying to write multiple IF conditions in a SQL statement. I would like to know that if SMB is 1, then check that ACT, REN or REP is 1, select the QF column from the resp table and I am the same as my yoga as an 'A' and 'B' Want answer

Input: @ SMB = 1, @ Dealer = 0, @ Act = 1, @ Rain = 1, Rp = 1 TLAATT: QF 1 2 TLREP QF 1 2 TLREN QF 1 Output: Now choose 0 0 @ SMB bit = 1, Dealter bit = 1, @ Act bit = 1, @ Rain bit = 1, @ Riff bit = 1 SUM (TBLA), from SM (TBL) (if @ SMB = 1 'if In the case of QF (1, 2) then in the case of 1 or 1, when QF (4,5) then 1 ELS B in the case of TLAAT Unit, all if @REN = '1' case QF IN (1,2) 1 ELSE 0 As a matter of when QF IN (4,5) then 1 @ ELSE 0b, all @ REP = '1' case from T-BLEEN union when QF IN (1,2) then 1 ELSE 0 case As when QF IN (4,5) then 1 ELSE 0B as the tblREP union all if @dialer = '1' if @ct = 1 'in the case of QF (1, 2) then the case of 1 0 In the form when QF IN (4,5) then 1 ELSE 0B as TblACT union all in the @REN = '1' case when QF IN (1,2) then 1 ELSE 0 as a case when QF IN (4,5) then all @ RE from TLREN union as 1 ELSE 0B ी = '1' in case when QF IN (1,2) then 1 or 1 as a case when QF IN (4,5) then 1 ELSE 0 as B to tblREP) tbl

Try it out and tell me. Insert into the #tmp values ​​(4) Insert into #tmp values ​​(4) #tmp values ​​in Insert in the #tmp values ​​(1) INSERT #tmp values ​​

  create table #tmp (QF INT) Enter (4) Include in #tmp values ​​(5) DECLARE @SMB bit, @ dealer bit, @ act bit, @ ray bit, @ rp bit sET @ smb = 1 sET @dilator = 1 st @ act = 1 sET Select @Arn = 1 SET @ RIP = 1 SAM ((SSB = 1 or DALR = 1) and AECT = 1 and QF IN (1, 2) then 1 WHEN (@ SMB = 1 OR @ Dialer = 1) and @REN = 1 and QF IN (1, 2) then 1 when (@ SMB = 1 or @ dialer = 1) and @REP = 1 and QF IN (1, 2) then 1 ELSE 0 END). , SM (@ (SMB = 1 or @ Dealer = 1) and @ AATT = 1 and QF in (4, 5) then 1 wine (@ SMB = 1 or @ dialer = 1) and @re = 1 and QF IN (4, 5) then 1 when (@ SMB = 1 or @ dialer = 1) and @Rep = 1 and QF IN (4, 5) then 1 ELSE 0 END)) #BTM  / Pre > 

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -