例如字段title和detail里有的放最前面
接着是只有在title有的
最后是只有detail里有的可以吗?
接着是只有在title有的
最后是只有detail里有的可以吗?
解决方案 »
- 我电脑上先安装了sql2005然后再安装sql2000
- sql
- sql server 2008 有关数据库日志查询和数据库备份问题。
- 《Microsoft SQLServer2000 宝典》这本书怎么样?在线等待
- 有没有办法像事件探查器一样查看SQL语句的执行用户是谁?
- 在表属性中有一个创建unique中有约束和索引,这个约束是什么意思,感谢
- MSSQL2008 数据库用户链接【数据库引擎】登录失败,系统:Windows 2008 Server
- 求SQL2000负库存判断和控制 触发器
- 存储过程调用存储过程的参数问题
- select 的奇怪问题
- 有什么比较有效率的删除重复内容的方法
- mysql支持10000的数据吗?
when title<>'' then 1 end
-----------
思路
select * from tablename
order by case when title is not null and details is not null then 0
when title is not null and details is null then 1
else 2 end
create table tablename(title varchar(10),details varchar(10))insert into tablename
select 'abc','ok'
union
select null,'efg'
union
select 'dfjkd',nullselect * from tablename
order by case when title is not null and details is not null then 0
when title is not null and details is null then 1
else 2 end
接着是只有在title有的
最后是只有detail里有的 可以吗?select * from tb where charindex('关键字' , title) > 0 and charindex('关键字' , detail) > 0
union
select * from tb where charindex('关键字' , title) > 0 and charindex('关键字' , detail) = 0
union
select * from tb where charindex('关键字' , title) = 0 and charindex('关键字' , detail) > 0