简体   繁体   English

如果SQL查询成功,如何返回一个行值,否则返回另一个行值?

[英]How do I return one row value if a sql query succeeds and another otherwise?

如果SQL查询成功,如何返回一个行值,否则返回另一个行值?

I presume you want to use IF EXISTS. 我想您想使用IF EXISTS。 If so, this might help: http://www.sqlteam.com/article/using-exists 如果是这样,这可能会有所帮助: http : //www.sqlteam.com/article/using-exists

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在SQL中,如何获取具有特定列值的行(如果有),否则如何获取其他行 - In SQL, how do I fetch a row with a specific column value if available, otherwise any other row 当另一行具有相同的 id 但列中的值不同时,如何在 SQL 中选择一行? - How do I select one row in SQL when another row has same id but a different value in a column? 如何基于另一个列值在非聚合的SQL查询中返回最大值 - How do I return max value in a non-aggregated sql query based on another column value 对于SQL一列中的相同ID,如何为另一列中值较大的行编写Case语句? - For the same ID in one column of SQL, how do I write a Case statement for the row with the greater value in the another column? 我如何使用sql在一行中仅返回一部分值 - how do i return only a part of value in a row using sql 如何更改查询以仅显示一行 SQL? - How do I change the query to just show one row SQL? 如何将一列的值复制到同一行的另一列? - How do I copy the value of one column into another in the same row? 如何从 SQL 的另一行中取最小值? - How do I take the minimum value from another row in SQL? 当变量为空时,我如何使SQL语句返回所有行,否则仅返回匹配项 - How do I make an SQL statement to return all rows when a variable is blank, otherwise return only matches 关于如何从另一个表中获取随机记录到另一个表上的每一行的查询的 SQL 查询? - SQL query on how do I get a random record from another table into a query on another table for every row?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM