相关文章推荐
要出家的钥匙扣  ·  比亚迪汉、几何C、蔚来EC6领衔,下半年5款 ...·  6 月前    · 
潇洒的蚂蚁  ·  团学工作_中国人民大学哲学院·  1 年前    · 
温文尔雅的紫菜汤  ·  jquery修改整个页面的字体大小_mob6 ...·  1 年前    · 
兴奋的沙滩裤  ·  果不其然,宁德时代在美电池工厂项目或被叫停, ...·  2 年前    · 
痴情的铁板烧  ·  哥布林洞窟 - 百度·  2 年前    · 
Code  ›  How do I add a if condition in SQL Query? | OutSystems
join
https://www.outsystems.com/forums/discussion/65352/how-do-i-add-a-if-condition-in-sql-query/
会搭讪的骆驼
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...
 
推荐文章
要出家的钥匙扣  ·  比亚迪汉、几何C、蔚来EC6领衔,下半年5款重磅新能源车盘点-新浪汽车
6 月前
潇洒的蚂蚁  ·  团学工作_中国人民大学哲学院
1 年前
温文尔雅的紫菜汤  ·  jquery修改整个页面的字体大小_mob649e816a3664的技术博客_51CTO博客
1 年前
兴奋的沙滩裤  ·  果不其然,宁德时代在美电池工厂项目或被叫停,美国称有安全风险 - 知乎
2 年前
痴情的铁板烧  ·  哥布林洞窟 - 百度
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号