表A 中有一列B B列是用户名,里面有含英文的,有0开头的,有1开头的,这三种,现想用语句查询者三种,该怎么写?含英文的:select * from A where ***0开头的:select * from A where ***1开头的:select * from A where ***
解决方案 »
- 有人用软件不停的尝试登录我的数据库服务器,应该怎么屏蔽这个IP
- sql2005关于视图,急。。在线等
- 取表中某分类,最后一天或两天的数据?
- 请问这个SQL查询怎么实现,非常感谢,请进
- sql server数据库连接的方法有几种(asp.net中)
- 小小問,GG help me
- 请教:对于复选框里传来的内容怎么保存好?
- 用PB怎样备份恢复后台SQL Server2000数据库,急急急
- VFP高手们,给小弟介绍一本VFP的好书吧,谢谢!
- 求教大家:我想取出每个分类最新的一条记录,然后联合,但是union中的order by 无法使用?如何解决?谢谢!!!
- 丢包问题
- 如何SQL2000中设置链接ORACLE8.0数据库
use tempdb;
/*
create table A
(
B nvarchar(10) not null
);
insert into A values('CDE'),('0AB'),('1CD');
*/
select A.B as [字母开头] from A
except
(
select A.B as [0开头] from A where A.B like '0%'
union
select A.B as [1开头] from A where A.B like '1%'
);
select A.B as [0开头] from A where A.B like '0%';
select A.B as [1开头] from A where A.B like '1%';
declare @t table (col varchar(8))
insert into @t
select '09234234' union all
select '13245255' union all
select '0234234a' union all
select '1gfsss45' union all
select '2sdfsfsf' union all
select '43645764'select * from @t where left(col,1)='0'
/*
col
--------
09234234
0234234a
*/
select * from @t where left(col,1)='1'
/*
col
--------
13245255
1gfsss45
*/
select * from @t where patindex('%[a-z]%',col) > 0
/*
col
--------
0234234a
1gfsss45
2sdfsfsf
*/
select * from #a where b like '0%'
select * from #a where b like '%[A-Z]%'