SQL语句精简版
Posted mdge
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL语句精简版相关的知识,希望对你有一定的参考价值。
select US.QQ,US.tel,US.username,SC.EnglishScore,SC.MathScore
from Userinfor US right join Score SC on US.UserID=SC.UserID
select US.QQ,US.tel,US.username,SC.EnglishScore,SC.MathScore
from Userinfor US left join Score SC on US.UserID=SC.UserID
select US.userID,US.QQ,US.tel,US.username,SC.EnglishScore,SC.MathScore
from Userinfor US inner join Score SC on US.UserID=SC.UserID
select uss.userid,USS.username,USS.MathScore,PSs.father,PSS.mother
from (select US.userID,US.QQ,US.tel,US.username,SC.EnglishScore,SC.MathScore
from Userinfor US inner join Score SC on US.UserID=SC.UserID
) uss left join Parents PSS on USS.UserID=PSS.userID
select * from UserInfor
select top 3 * from
(select ROW_NUMBER() over( order by userid)as rownumber,* from UserInfor) A
where rownumber>6
select userid,username,age,
case
when age<=25 then ‘小学生‘
when age>25 and age<30 then ‘中学生‘
else ‘大学生‘
end as usergrade from userinfor
select userid,username,age,
case
when age=25 then ‘小学生‘
when age>25 and age<30 then ‘中学生‘
else ‘大学生‘
end as usergrade from userinfor
select * from UserInfor
select top 3 * from
(select ROW_NUMBER() over (order by userid)as rownumber,* from UserInfor )
A
where rownumber>0
select top 3* from(
select ROW_NUMBER() over (order by userid)as rownumber,*from UserInfor
)A
where rownumber>3
select * from userinfor
select userid,username,age,
case
when age<=25 then ‘小学生‘
when age between 25 and 30 then ‘中学生‘
else ‘大学生‘
end as usergrade from userinfor
select *from score
select ui.userid, ui.username,ui.qq,ui.tel,sc.EnglishScore,sc.mathscore from UserInfor ui left join
score sc on ui.userid=sc.userid
select * from Parents
select uss.userid,uss.tel,uss.mathscore,ps.father,ps.mother from
(select ui.userid, ui.username,ui.qq,ui.tel,sc.EnglishScore,sc.mathscore from UserInfor ui left join
score sc on ui.userid=sc.userid) uss left join Parents ps on uss.userid=ps.userid
select * from userinfor
select top 3 * from(
select ROW_NUMBER() over (order by userid)as rownumber,*from UserInfor
)A where rownumber>0
当看到script标签和调用function的时候进入JS作用域
进入作用域进行1111111111111111111111111111111.JS预解析开辟一个空间有没有var,有没有方法参数,就会把var和方法参数,声明的变量赋值为undefined,
222222222222222222222222222222.JS逐行执行就是去找有没有表达式++=====-----有的话就把JS作用域里面的变量的值做修改.
请问什么是RESTful,我回答的是get post put delete等请求规范,每个关键字都有特定的意义,遵循这样的风格进行前后台分离开发。问到了javascript 的call apply bind,Promise相比之前的技术,有什么进步?答它主要是可以解决深度回调的问题吧,因为在异步操作里面你必须要等完成继续下一步操作,会形成深度回调。而Promise可以return Promise 通过then解决,箭头函数的this永远指向当前对象,这个,因为我是写C#出生的,所以这个也是我非常熟悉的。Ajax跨域访问需要注意什么问题,答,一般在开发的时候,都会直接AccessControlAllowOrigin*,正式发布需要进行一些配置。jsonp跨域需要和后台约定jsonpCallback,对于OPTIONS复杂请求需要多一个判断返回200,你在gulp中主要用些什么,sass babel转码js合并丑化css的自动补全。合并,压缩。谈谈MVC和MVVM的区别,这个问的我最懵逼的,因为一直在用,Java后台MVC模式,前端的框架MVVM比如Vue,比如说{}是实例对象,它仅仅只有一个__proto__,而函数对象才会有prototype,举例,function Person(){} Person.prototype就是new Person()的原型对象。Person.__proto__是等于Function.prototype的,答:Function.prototype.__proto__又是等于Object.prototype的,。然后开始问Vue,你在你写的那个项目里面,是怎么用Vue,我说我就仅仅把它当做一个操作DOM的便利的工具,没有应用webpack,那你用过Vuex吗,嗯,自己写一些小测试体验过,通过讲状态集中管理,避免了兄弟组件之间管理状态的混乱。
分页:
//下一页
function next() {
var roleName = $("input[name=‘roleName‘]").val();
var pagesize = $("input[name=‘pageSize‘]").val();
var pageIndex = parseInt($("#currpage").text()) + 1;
var lastpagenum = $("#lastpage").text();
if (parseInt(pageIndex) > parseInt(lastpagenum));
{
pageIndex = lastpagenum;
}
$.ajax({
type: "get",
url: "../Role/RoleData",
dataType: "json",
data: { roleName: roleName, pageSize: pagesize, pageIndex: pageIndex },
success: Suc
});
}
//上一页
function BackPage() {
var roleName = $("input[name=‘roleName‘]").val();
var pagesize = $("input[name=‘pageSize‘]").val();
var pageIndex = parseInt($("#currpage").text()) - 1;
if (parseInt(pageIndex) < 1);
{
pageIndex = 1;
}
$.ajax({
type: "get",
url: "../Role/RoleData",
dataType: "json",
data: { roleName: roleName, pageSize: pagesize, pageIndex: pageIndex },
success: Suc
});
}
//尾页
function WeiPage() {
var roleName = $("input[name=‘roleName‘]").val();
var pagesize = $("input[name=‘pageSize‘]").val();
var pageIndex = $("#lastpage").text();
$.ajax({
type: "get",
url: "../Role/RoleData",
dataType: "json",
data: { roleName: roleName, pageSize: pagesize, pageIndex: pageIndex },
success: Suc
});
}
拿数据的方法,我们只需要得到当前页(pageindex)和(pagesize)每页显示多少,再加上你的查询条件,一起传给数据访问层那个方法就能拿到对应数据做返回了
131-帘外月朦明-男 2018/1/9 星期二 下午 10:43:59
下面是前端List页面代码
$(function () {
serach();
});
//查询
function serach() {
var roleName = $("input[name=‘roleName‘]").val();
var pagesize = $("input[name=‘pageSize‘]").val();
var pageIndex = 1;
$.ajax({
type: "get",
url: "../Role/RoleData",
dataType: "json",
data: { roleName: roleName, pageSize: pagesize, pageIndex: pageIndex },
success: Suc
});
};
function Suc(JData) {
if (JData.Data) {
$(".mt-20 table tbody").empty();
var strTable = "";
var intCount = JData.Data.length;
var strStatus = "";
var strUrl = "";
for (var i = 0; i < intCount; i++) {
strTable += "<tr class=‘text-c‘ style=‘height:18px‘><td align=‘center‘><input type="checkbox" value="" + JData.Data[i].ROLE_ID + "" name="Chk" /></td>";
strTable += "<td align=‘center‘>" + JData.Data[i].ROLE_ID + "</td>";
strTable += "<td align=‘center‘>" + JData.Data[i].DeptName + "</td>";
strTable += "<td align=‘center‘>" + JData.Data[i].ROLE_NAME + "</td>";
strTable += "<td class=‘text-l‘>" + JData.Data[i].CREATOR + "</td>";
strTable += "<td>" + gettime(JData.Data[i].CREAT_TIM) + "</td>";
strTable += "<td class=‘text-l‘>" + JData.Data[i].REVISER + "</td>";
strTable += "<td >" + gettime(JData.Data[i].REVIS_TIM) + "</td>";
strStatus = JData.Data[i].STATUS;
strTable += "<td class=‘td-status‘><span class=‘label label-success radius‘>" + GetStatus(strStatus) + "</span></td>";
strTable += "<td class=‘f-14 td-manage‘>";
strTable += GetButtonStart(strStatus, JData.Data[i].ROLE_ID);
strTable += GetButtonStop(strStatus, JData.Data[i].ROLE_ID);
strTable += "<a title=‘编辑‘ href=‘javascript:;‘ onclick="member_edit(this, ‘" + JData.Data[i].ROLE_ID + "‘)" style=‘text-decoration:none;margin:0 0 0 5px‘><i class=‘Hui-iconfont‘></i></a>";
strTable += "<a title=‘删除‘ href=‘javascript:;‘ onclick="member_del(this, ‘" + JData.Data[i].ROLE_ID + "‘)" style=‘text-decoration:none;margin:0 0 0 5px‘><i class=‘Hui-iconfont‘></i></a>";
strTable += "<a title=‘选择产品‘ href=‘javascript:;‘ onclick="getGoodsByRoleId(this, ‘" + JData.Data[i].ROLE_ID + "‘)" style=‘text-decoration:none;margin:0 0 0 5px‘><i class=‘Hui-iconfont‘></i></a></td></tr>";
}
$("#RegionTable tbody").append(strTable);
$(".totalpage").html(JData.DataTotal);//总行数
$(".total").html(JData.totalPage);//总页
$("#currpage").text(JData.pageIndex);//当前页
}
};
function GetStatus(status) {
if (parseInt(status) == 1)
return ‘已启用‘;
else
return ‘已禁用‘;
}
function GetButtonStart(status, levelid) {
if (parseInt(status) != 1) {
return "<a style=‘text-decoration:none‘ onclick="member_start(this, ‘" + levelid + "‘)" href=‘javascript:;‘ title=‘启用‘> <i class=‘Hui-iconfont‘></i></a>";
}
else {
return "<a class=‘adisabled‘ style=‘text-decoration:none‘ onclick="member_start(this, ‘" + levelid + "‘)" href=‘javascript:;‘ title=‘启用‘> <i class=‘Hui-iconfont‘></i></a>";
}
}
function GetButtonStop(status, levelid) {
if (parseInt(status) == 1) {
return "<a style=‘text-decoration:none;margin:0 5px 0 5px;‘ onclick="member_stop(this, ‘" + levelid + "‘)" href=‘javascript:;‘ title=‘禁用‘><i class=‘Hui-iconfont‘></i></a>";
}
else {
return "<a class=‘adisabled‘ style=‘text-decoration:none;margin:0 5px 0 5px;‘ onclick="member_stop(this, ‘" + levelid + "‘)" href=‘javascript:;‘ title=‘禁用‘><i class=‘Hui-iconfont‘></i></a>";
}
}
下面这个是控制器中返回ajax请求数据,类似这样的可以写再.ashx(一般处理程序中)
public ActionResult RoleData()
{
int intPageSize = int.Parse(Request.QueryString["pageSize"] != null ? Convert.ToString(Request.QueryString["pageSize"]) : "");
int intPageIndex = int.Parse(Request.QueryString["PageIndex"] != null ? Convert.ToString(Request.QueryString["PageIndex"]) : "");
string strRoleName = Request.QueryString["roleName"] != null ? Convert.ToString(Request.QueryString["roleName"]) : "";
Expression<Func<DMS_ROLE_INF, bool>> lambdaWhere = null;
lambdaWhere = lambdaWhere.And<DMS_ROLE_INF>(x => 1 == 1);
int intTotalCount = 0;
if (!string.IsNullOrEmpty(strRoleName))
{
lambdaWhere = lambdaWhere.And<DMS_ROLE_INF>(x => x.ROLE_NAME.Contains(strRoleName));
}
List<DMS_ROLE_INF> lstLevel = _ibssession.CreateDMS_ROLE_INF.GetModels<int>(lambdaWhere, intPageIndex, intPageSize, out intTotalCount, x => x.ROLE_ID, true).ToList();
int inttotalPage = GetTotalPage(intTotalCount, intPageSize);
List<Models.DBModelsExt.Role> lstRole = new List<Models.DBModelsExt.Role>();
lstRole = Common.DBModelsExt.ModelsTModelsExt<DMS_ROLE_INF, Models.DBModelsExt.Role>.Convert(lstLevel);
lstRole.ForEach(x => x.DeptName = GetDeptName(x.DEPARDMENT_ID));
AjaxMsgModel ajaxmsgmodel = new AjaxMsgModel()
{
Statu = AjaxStatuEnum.success,
Msg = "ok",
Data = lstRole,
BackUrl = "",
DataTotal = intTotalCount,
pageIndex = intPageIndex,
pageSize = intPageSize,
totalPage = inttotalPage
};
return Json(ajaxmsgmodel, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 分页查询表数据
/// </summary>
/// <typeparam name="TKeyType">排序时使用的数据类型<peparam>
/// <param name="excWhere">查询Lambda表达式目录树</param>
/// <param name="pageIndex">页索引</param>
/// <param name="pageSize">页记录数</param>
/// <param name="totalCount">总记录数</param>
/// <param name="excOrderby">排序Lambda表达式目录树</param>
/// <param name="isAsc">升序OR降序,True升序,False降序</param>
/// <returns></returns>
public IQueryable<T> GetModels<TKeyType>(Expression<Func<T, bool>> excWhere, int pageIndex, int pageSize, out int totalCount, Expression<Func<T, TKeyType>> excOrderby, bool isAsc)
{
IQueryable<T> tmp = _dbContext.Set<T>().Where<T>(excWhere);
totalCount = tmp.Count<T>();
if (isAsc)
{
return tmp.OrderBy(excOrderby).Skip((pageIndex - 1) * pageSize).Take(pageSize);
}
else
{
return tmp.OrderByDescending(excOrderby).Skip((pageIndex - 1) * pageSize).Take(pageSize);
}
}//这个C#数据访问层EF框架下服务器端分页的
public class AjaxMsgModel
{
public string Msg { get; set; }
public AjaxStatuEnum Statu { get; set; }
public string BackUrl { get; set; }
public object Data { get; set; }
public int DataTotal { get; set; }
public int pageIndex { get; set; }
public int pageSize { get; set; }
public int totalPage { get; set; }
}
以上是关于SQL语句精简版的主要内容,如果未能解决你的问题,请参考以下文章