惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

量子位
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
博客园 - 司徒正美
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
L
LangChain Blog

博客园 - 落木

PowerDesigner中NAME和COMMENT的互相转换,需要执行语句 获取网站根目录的urli源代码 - 落木 - 博客园 Control的Invoke和BeginInvoke 用.net的GetCallbackEventReference函数来实现dropDownList联动的ajax效果 处理SQLSERVER死锁(转载) 调用DirectX进行简单的多媒体编程系列(四) 调用DirectX进行简单的多媒体编程系列(三) 调用DirectX进行简单的多媒体编程系列(二) 调用DirectX进行简单的多媒体编程系列(一) 数据库分页算法 mysql想说爱你不容易啊,从mssql迁移到mysql时,几乎所有的存储过程都得改,语法相差很大,累人!! 自己写的sqlserver和mysql的行转列通用存储过程 MSSQL优化文章 C#中编写sqlserver中自定义函数,实现复杂报表 Ajax使用Post方式提交到.aspx页面交互的例子 核单台帐表(存储过程) 清欠率(存储过程) ExtJS中的面向对象设计,组件化编程思想 - 落木 - 博客园 ExtJS中如何扩展自定义的类
扩大范围的多条件查询
落木 · 2010-05-11 · via 博客园 - 落木

代码

declare @TempTab Table(id int,a varchar(50),b varchar(50),c varchar(100));
insert into @TempTab(id,a,b,c) values(1,'aaa111','bbb111','ccc111');
insert into @TempTab(id,a,b,c) values(2,'aaa222','bbb222','ccc222');
insert into @TempTab(id,a,b,c) values(3,'aaa333','bbb333','ccc333');
insert into @TempTab(id,a,b,c) values(4,'aaa444','bbb444','ccc444');
insert into @TempTab(id,a,b,c) values(5,'aaa555','bbb555','ccc555');
select * from @TempTab;declare @q_a varchar(50);
declare @q_b varchar(50);
declare @q_c varchar(50);
set @q_a='aaa111';
set @q_b='bbb222';
set @q_c='ccc111';
--set @q_a='aaa111';
--
set @q_b='bbb222';
--
set @q_c='ccc333';

declare @count int
select @count=count(*from @TempTab where a=@q_a and b=@q_b and c=@q_c
if @count>0
    
begin
        
select * from @TempTab where a=@q_a and b=@q_b and c=@q_c
    
end
else
    
begin
        
select @count=count(*from @TempTab where (a=@q_a and b=@q_bor (a=@q_a and c=@q_cor (b=@q_b and c=@q_c)
        
if @count>0
            
begin
                
select * from @TempTab where (a=@q_a and b=@q_bor (a=@q_a and c=@q_cor (b=@q_b and c=@q_c)
            
end
        
else
            
begin
                
select @count=count(*from @TempTab where a=@q_a or b=@q_b or c=@q_c
                
if @count>0
                    
begin
                        
select * from @TempTab where a=@q_a or b=@q_b or c=@q_c
                    
end
                
else
                    
begin
                        
select * from @TempTab
                    
end
            
end
    
end

代码

declare @orgcity varchar(200);
declare @dstcity varchar(200);
declare @FromTime DATETIME;
declare @flightNo varchar(50);
declare @AirCompanyCode varchar(50);
declare @CabinType varchar(50);set @orgcity='CAN';
set @dstcity='XIY';
set @FromTime='2010-05-08 00:00:00:000';
set @flightNo='cz3208';
set @AirCompanyCode='cz';
set @CabinType='u';SELECT * FROM SpecialManager where 
(
@FromTime between Orgdate and DstDate and orgcity like '%'+@orgcity+'%' and dstcity like '%'+@dstcity+'%' and specialType=0)SELECT  top 1 * FROM SpecialManager where (@FromTime between Orgdate and DstDate and orgcity like '%'+@orgcity+'%' and dstcity like '%'+@dstcity+'%' and specialType=0and (flightNo=@flightNo  OR ISNULL(flightNo,'')=''AND (AirCompanyCode=@AirCompanyCode  OR ISNULL(AirCompanyCode,'')=''AND (CabinType like '%'+@CabinType+'%'  OR ISNULL(CabinType,'')=''ORDER BY AirCompanyCode desc,flightNo desc,CabinType desc