一列数据库的最大值 [英] maximum value of a column of data base
本文介绍了一列数据库的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
推荐答案
可能使用 ^ ].实现 IDbCommand [ OleDbCommand [
Probably using ADO.NET[^]. An Object Implementing IDbCommand[^] can take your query. In case of Access the OleDbCommand[^].
Dim cmd As New OleDbCommand("SELECT MAX(MyColumn) FROM MyTable", connection) ' connection is an IDbConnection Object, OleDbConnection here.
Dim maxValue As Integer = cmd.ExecuteScalar
如果您使用的是像LINQ to XML或Entity Framework LINQ这样的ORM可以解决问题.
In case you''re using an ORM like LINQ to XML or Entity Framework LINQ would do the trick.
Dim i As Integer = context.MyTable.Max(Function(o) o.MyValue)
希望对您有所帮助:)
Hope it helps :)
使用MAX
函数(假设您要从tablename
表中获取columnname
):
Use theMAX
function (assuming you want thecolumnname
from thetablename
table):
select MAX(columnname) from [tablename]
这篇关于一列数据库的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文