如果没有where子句,请选择工资大于500的行 [英] Select row having salary greater than 500 without where clause

查看:112
本文介绍了如果没有where子句,请选择工资大于500的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选择薪水大于500而没有where子句的行



表名:员工

Select row having salary greater than 500 without where clause

Table Name:Employee

Empid Empname salary
1       A      100
2       B      600
3       C      700
4       D      200
5       E      900



输出:


output:

Empid Empname salary
2       B      600
3       C      700 
5       E      900

推荐答案

你不能。除非你有某些描述的条件子句,否则SQL将始终返回所有记录。



通过移动WHERE,你很可能通过JOIN来完成它条件进入ON子句,但没有充分的理由这样做,当WHERE更有效,更容易理解!
You can't. Unless you have a conditional clause of some description, SQL will always return all records.

It is vaguely possible that you could do it with a JOIN, by moving the WHERE condition into the ON clause, but there is no good reasons to do that when the WHERE is much more efficient, and understandable!


其中子句可以帮助你过滤结果集并处理较小的数据子集。

老实说,你真的不应该考虑没有 where 子句。



关于没有where子句的查询,这里是你可以做的。

在表格上运行查询将结果移动到游标。



遍历游标,如果元素大于临时变量,则将元素值移动到临时变量中。 />
一旦循环结束,最大值将在此临时变量中。
Where clause would help you filter the result set and work on a smaller subset of data.
So honestly, you should not really think about not having the where clause.

Regarding a query without a where clause, here is what you can do.
Run a query on the table and move the result to a cursor.

Loop through the cursor, and for element move the salary value into a temporary variable if it is greater than the temporary variable.
Once the loop ends, the maximum value will be in this temporary variable.


这篇关于如果没有where子句,请选择工资大于500的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆