当前位置:Gxlcms > 数据库问题 > sql常用语句

sql常用语句

时间:2021-07-01 10:21:17 帮助过:3人阅读

1、得到最大id      根据某个字段在某张表中

string strsql = "select max(" + FieldName + ")+1 from " + TableName;

2、是否存在该记录   根据id查找

StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from tpwellbase0");
strSql.Append(" where ID=@ID");

3、增加一条数据     根据model增加

StringBuilder strSql=new StringBuilder();
strSql.Append("insert into tpwellbase0(");
strSql.Append("wellname,oil_pro_plant,block)");
strSql.Append(" values (");
strSql.Append("@wellname,@oil_pro_plant,@block)");

4、更新一条数据  根据model更新

StringBuilder strSql=new StringBuilder();
strSql.Append("update tpwellbase0 set ");
strSql.Append("wellname=@wellname,");
strSql.Append("oil_pro_plant=@oil_pro_plant,");
strSql.Append("block=@block");
strSql.Append(" where ID=@ID");

5、删除一条数据 根据id

StringBuilder strSql=new StringBuilder();
strSql.Append("delete from tpwellbase0 ");
strSql.Append(" where ID in ("+IDlist + ") ");

6、得到一个对象实体 根据id获取改行model

StringBuilder strSql=new StringBuilder();
strSql.Append("select ID,wellname,oil_pro_plant,block from tpwellbase0 ");
strSql.Append(" where ID=@ID");

7、获得数据列表list<model>

8、分页获取数据 dataset格式

 

sql常用语句

标签:

人气教程排行