1.查询语句的基本操作 - select - from - where - group by - having - distinct - order by - limit - 聚合函数: count, max, min, avg, sum 2.单表查询: #前期表与数据准备 # 创建一张部门表 create table emp( id int not null unique auto_increment, name ) not null, sex enum('male','female') no…
单表查询 前期表准备 create table emp( id int not null unique auto_increment, name varchar(20) not null, sex enum('male','female') not null default 'male', #大部分是男的 age int(3) unsigned not null default 28, hire_date date not null, post varchar(50), post_comment…
看到朋友再写一个SQL语句:两个表a1表中有SN.SN2.TN,b1表有SM.SM2.TN2,若a1的SN中的数据和b1的SM中的数据是一致的,那么将a1中对应的数据修改成b1中对应的数据. update a1 set SN2 = (select B1.SM2 from b1 where A1.SN = B1.SM),TN = (select B1.TN2 from b1 where A1.SN = B1.SM) where a1.SN in (select SMfrom b1);…
1.查询单表 var pageSize = 2;//条数 var pageIndex = 2;//索引 var sql = @" SELECT D.* FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY B_MemberId ASC ) AS rownum , * FROM Bxy_MembersData ) AS D WHERE rownum BETWEEN ( @pageIndex - 1 ) * @pageSize + 1 AND @pageIndex *…
本文转载自:http://hi.baidu.com/ajyajyajy/item/4e2a7f4dc83393d2c1a592c1 use DBNAMEgoselect * from sysobjects where xtype='U'; --这是查询所有表的信息select count(*) from sysobjects where xtype='U' --这是查询表的数量 select a.name, b.rows from sysobjects a with(nolock) join…