如何在选择语句中使用IF条件. [英] How to use the IF condition in select statement....
本文介绍了如何在选择语句中使用IF条件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
E_ID E_IP E_TYPE
E00003 192.168.0.131 E
E00003 192.168.0.131 B
E00003 192.168.0.131 B
E00003 192.168.0.131 E
E00003 192.168.0.131 E
E00003 192.168.0.131 B
E00003 192.168.0.131 X
192.168.0.131 X
E00003 192.168.0.131 E
E00004 192.168.0.131 B
我想使用IF条件选择sql查询...如果E_TYPE列是E和B我想显示E和B的行,如果E_TYPE列是X我只想显示X的行....
I want select sql query using IF condition...If the E_TYPE Column is E and B i want to display the rows of E and B and if E_TYPE column is X i want to display the X rows only....
推荐答案
不确定您的意思,但 ^ ].
在SELECT语句中,使用时,可能会更好,更容易.然后... ELSE ... [
Not sure what you mean, but here is how to use IF... ELSE in SQL[^].
In a SELECT statement it would probably be better and easier to use CASE WHEN... THEN... ELSE...[^].
The MSDN documentation on these is actually pretty good, complete with examples. So I am not going to explain them again here. Simply check out the links and you should manage :)
这篇关于如何在选择语句中使用IF条件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文