selectu.id,u.nicename,u.imei,u.address,u.mobile,fromusersasu,(selectcount(imei)次数,imeifromrebackwhereconvert(varchar(10),[time],120)='2012-11-06'groupbyimei)vwherev.imei=u.imeiorderbyv.次数desc你写的重复查询的太多了,整体结构不好。
- 情感问答
- 答案列表
sql 一对多查询:sql一对多关联查询[朗读]
selectt1.id,t1.name,t2.typefromt1leftouterjoint2ont1.id=t2.idandt2.pid='1'要是只显示t2中pid的奇数时selectt1.id,t1.name,t2.typefromt1leftouterjoint2ont1.id=t2.idandt2.pid%2=1这时可以得出你想要的结果.不知你想要的是不是这样的编辑.希望能给你点帮助。
如果你的表有主键那就用selectcount(主键)from表名.这样写对数据的优化有好处。
select表a.typeid,表b.namefrom表a,表bwhere表a.typeid=表b.keyvalueand表b.id='typeid'。
intpagecount=15(每页显示的行数)inttotalcount=30(页数*每页显示的行数),这里是第二页stringsearchstring=xxxxxx(搜索条件)selecttoppagecount*from表名whereidnotin(selecttoptotalcountidfrom表名wheresearchstring)wheresearchstringorderbytimedesc然后下个aspnetpage的分页控件就行了,以上是分页的sql语句。