复杂的查询
来源:互联网 发布:2018年中国经济知乎 编辑:程序博客网 时间:2024/05/01 01:40
CREATE PROCEDURE [dbo].[User_Module]
(@UserName nvarchar(20),
@UserPwd nvarchar(20))
AS
select 权限表.用户权限 from 权限表
where (权限表.Id in (select 用户权限表.权限表Id from 用户权限表
where 用户权限表.角色表Id in (select 角色表.Id from 角色表
where 角色表.用户表Id = (select 用户表.Id from 用户表 where
用户表.用户名 = @UserName and 用户表.用户密码 = @UserPwd ))))
GO
select 用户表.id,
用户表.name ,
权限表.action,
角色表.groupname
from 用户表,
角色表,
用户角色表,
权限表,
角色权限表
where 用户表.id=用户角色表.id
and 用户表.id=角色权限表.id
and 用户角色表.groupid =角色表.groupid
and 角色权限表.actionid=权限表.actionid
//设置查询语句
string strSql = "SELECT * FROM StudentInfo ";
//设置查询条件
string strSql1 = "";
//如果studentid(学号)输入框的内容不为空的话,
if (this.studentid.text!="")
{
//判断查询条件是否为空,如果为空的话,用where
if (strSql1.Length==0)
{
//加入查询条件
strSql1 = "WHERE (studentid = "+this.studentid.text+") ";
}
//如果不为空的话,用and
else
{
//加入查询条件
strSql1 += "and (studentid = "+this.studentid.text+") ";
}
}
//如果studentname(姓名)输入框的内容不为空的话,
if (this.studentname.text!="")
{
//判断查询条件是否为空,如果为空的话,用where
if (strSql1.Length==0)
{
//加入查询条件
strSql1 = "WHERE (studentname = "+this.studentname.text+") ";
}
//如果不为空的话,用and
else
{
//加入查询条件
strSql1 += "and (studentname = "+this.studentname.text+") ";
}
}
create proc spyourname
(
@name1 varchar(20),
@name2 varchar(20),
@name3 varchar(20),
@name4 varchar(20),
@name5 varchar(20)
)
WITH ENCRYPTION
as
set nocount on
declare @SQL varchar(5000)
set @SQL='select name1,name2,name3,name4,name5 from yourtable where 1=1 '
if @name<>''
set @SQL=@SQL+ ' and name1 like ''%'+@name+'%'''
if @belong1<>''
set @SQL=@SQL+ ' and name2 like ''%'+@belong1+'%'''
if @belong2<>''
set @SQL=@SQL+ ' and name3 like ''%'+@belong2+'%'''
if @belong3<>''
set @SQL=@SQL+ ' and name4 like ''%'+@belong3+'%'''
exec(@SQL)
- 复杂的查询
- 复杂条件的查询
- Subsonic的复杂查询
- 复杂点的查询
- 复杂的分页查询
- 表的复杂查询
- 更复杂的查询
- SQL复杂的查询
- 复杂查询的分页
- 复杂查询语句的使用
- 三、复杂的查询语句
- 复杂的ORACLE查询语句
- 复杂的sql数据库查询
- MTSQL 复杂的查询方法
- sql的复杂查询步骤
- oracle的基本查询和复杂查询
- 表的复杂查询---子查询
- 复杂查询
- AspJpeg v1.5.0.0 图片处理组件
- javascript创建控件
- How to Hack a coke machine
- 72个英语关键句型的理解及掌握
- 一个路痴的前世今生
- 复杂的查询
- asp.net 使用RGB定义颜色
- EssUP迭代核心——时间盒 Time boxing
- 简单.NET留言板架构
- 第一贴
- 主引导区的恶意程序
- 17种正则表达式
- 关于编码过滤的问题,这里使用在web.xml中添加过滤器的方法!
- tcpdump 侦测网络端口数据