相关文章推荐
踢足球的鸭蛋  ·  2025假牙材質全攻略,假牙價格、材質、特色 ...·  8 月前    · 
酒量小的滑板  ·  法式創意料理|品三國草船借箭刷兆豐卡享主廚料理乙份·  9 月前    · 
深情的卡布奇诺  ·  2013年蛇年春节对联大全·  9 月前    · 
逼格高的沙发  ·  为什么英伟达、AWS、阿里都喜欢Arm的服务 ...·  10 月前    · 
冷静的签字笔  ·  26岁的女性没有不孤独的,没有-虎嗅网·  10 月前    · 
小百科  ›  How do I add a if condition in SQL Query? | OutSystems
join
会搭讪的骆驼
2 年前
  • OutSystems.com
  • My Platform
  • Community
  • Support
OutSystems Logo
    • Guided Paths
    • Build an App
    • Training Planner
    • Courses
    • Developer Schools
    • Boot Camps
    • Certifications
    • Tech Talks
    • Overview
    • ODC
    • O11
  • Forums
  • Forge
    • Jobs
    • Ideas
    • Members
    • User Groups
  • Downloads
Log in
Sign Up
Community
/
Forums
/
Questions
UserImage.jpg
Alvin Teo
Rank: #14234
613 Views
2 Comments
Solved
How do I add a if condition in SQL Query?
Question

Hi Community,

I am looking to add an if condition in the query.

Something like this:

if {Notification).[SMSSeen]=1 , then run the LEFT JOIN {UserSMSRespond} ON {UserSMSRespond}.[MobileNumber] = {Ticket}.[ContactNo] else don't need run but assign {UserSMSRespond} .[Message] = " " (empty)



0
0
09 Oct 2020
Copy link to comment
2018-10-29 08-31-03
João Marques
MVP
Rank: #24
Solution

Hi Alvin,


You can use the CASE command to control the field output.

So on your SELECT statement, instead of {UserSMSRespond}.[Message] you want to add CASE WHEN {Notification}.[SMSSeen] = 1 THEN {UserSMSRespond}.[Message] ELSE '' END


The syntax for the CASE is: CASE (condition) THEN (output) ELSE (output) END .

In this case you control which value your field will have.


Regarding the LEFT JOIN you will need to have it there to be able to use the {UserSMSRespond}.[Message] (in case {Notification}.[SMSSeen] = 1).


Hope it helps.


Cheers,

João

0
0
09 Oct 2020
Copy link to comment
2023-08-08 18-12-50
Rahul Sahu
MVP
Rank: #68

Hi Alvin,

i think you  need to try like this

if @SMSSeen=1

your sql statement

Else

without join sql statement


or you can see some case in sql join

https://stackoverflow.com/questions/10256848/can-i-use-case-statement-in-a-join-condition


Regards

Rahul

1
0
09 Oct 2020
Copy link to comment
Log in to Answer
Log in to Answer Log in to Follow
OutSystems © - All Rights Reserved
55 Thomson Place
2nd Floor
Boston, MA 02210
Tel: +1 617 837 6840
More office locations
Legal
Website Terms of Use
Cookie Policy
Repository Terms of Use
Notice and Takedown Policy
Tools
IPP
Loading...
 
推荐文章
踢足球的鸭蛋  ·  2025假牙材質全攻略,假牙價格、材質、特色一次比較,選擇最適合 ...
8 月前
酒量小的滑板  ·  法式創意料理|品三國草船借箭刷兆豐卡享主廚料理乙份
9 月前
深情的卡布奇诺  ·  2013年蛇年春节对联大全
9 月前
逼格高的沙发  ·  为什么英伟达、AWS、阿里都喜欢Arm的服务器CPU? | 雷峰网
10 月前
冷静的签字笔  ·  26岁的女性没有不孤独的,没有-虎嗅网
10 月前
Link管理   ·   Sov5搜索   ·   小百科
小百科 - 百科知识指南