sql过滤英文
A. 在SQL数据库中,按照英文首字母对数据库中的汉字进行筛选
Create Function RmGetPY(@chn nchar(1))
returns char(1)
as
begin
declare @n int
declare @c char(1)
set @n = 63
select @n = @n +1,@c = case chn when @chn then char(@n) else @c end from(
select top 27 * from (
select chn =
'吖' union all select
'八' union all select
'嚓' union all select
'咑' union all select
'妸' union all select
'发' union all select
'旮' union all select
'铪' union all select
'丌' union all select
'丌' union all select
'咔' union all select
'垃' union all select
'呒' union all select
'拏' union all select
'噢' union all select
'妑' union all select
'七' union all select
'呥' union all select
'仨' union all select
'他' union all select
'屲' union all select
'屲' union all select
'屲' union all select
'夕' union all select
'丫' union all select
'帀' union all select @chn) as a
order by chn COLLATE Chinese_PRC_CI_AS
) as b
return(@c)
end
go
Create Function GetAllPY(@chn nvarchar(100))
returns varchar(30)
as
begin
declare @i int,@j int,@result varchar(100)
set @result=''
set @i=len(@chn)
set @j=1
while @j<=@i
begin
set @result = @result + dbo.RmGetPY(substring(@chn,@j,1))
set @j=@j+1
end
--将助记码限定在30个字母之内
select @result=(case when len(@result)>30 then left(@result,30) else @result end)
return @result
end
先加这两个函数,然后
select * from table where dbo.GetAllPY(字段) like 'J%'
B. sql 查询语句中如何过滤指定的字符
1、语句:SELECT * FROM dbo.Procts WHERE prod_name='king doll' AND prod_price>8。
--检索dbo.Procts表中所有列,过滤条件为由供应商king doll制造价格大于8的所有商品。
注意:--后面的字符是这条语句的注释,这条语句有两个条件,分别用AND关键字联接在一起,并且过滤结果必须满足这两个条件,如果只满足其中一个该数据不会被检索出来。
2、OR操作符(或)
语句:SELECT * FROM dbo.Procts WHERE prod_name='king doll' OR prod_price>8。
--检索dbo.Procts表中所有列,过滤条件为由供应商king doll制造价格大于8的所有商品值。
注意:--这里要说明的是OR操作符与AND操作符的不同之处是只要满足其中一个条件,数值就会被检索出来,例如:由供应商king doll制造价格小于8商品或者由供应商king add制造价格大于8的商品只要其中一个条件符合,数据就被检索出来。
3、IN操作符(指定条件范围)
语句:SELECT * FROM dbo.Procts WHERE prod_name IN ('king doll' ,'Queen dool')。
--检索dbo.Procts表中所有列,过滤条件为由供应商king doll和Queen dool制造的商品。
注意:它的功能其实和OR一样,但是它的执行速度会更快并且简洁,最大的优点是可以包含其他SELECT语句,能够更动态地建立WHERE字句。
C. 用SQL语句过滤数据
整个结果集来:
SELECT*FROM表
WHERE班级自=@班级参数
把DropDownList里绑上班级,根据你下拉的结果,把班级传给整个结果集,用于过滤
SELECTDISTINCT班级
FROM表
这样可以取出不重复的班级记录
最后把DropDownList取出的班级值@班级参数,传给结果集,这样结果集就可以根据你下拉框选的班级,动态过滤结果了。
D. sql server 如何过滤特殊字符
select * from T where PATINDEX(N'%[吖-咗]%',字段名来自) = 0
过滤英文
select * from T where PATINDEX(N'%[吖-咗]%',字段名) <> 0
过滤中文
朋友,点到为止,对你学习有好处。
E. SQL问题,如何筛选不包含英文字母
不知道你这个字段里具体有哪些类型数据?你可以用这个条件试试where
字段>=0
or
字段<=0
查看原帖>>
F. sql 语句 急!!!! 数据将英文和数字去掉,只保留汉字的sql语句
1、创建测试表,
create table test_replace_str(value varchar2(200));
4、编写语句,将英文和回数字去掉答,只保留汉字;
select t.*, regexp_replace(value, '[a-zA-Z0-9]', '') sec
from test_replace_str t;
G. SQL中怎样提取纯数字或者纯字母的字段
完全按照DB2语法设计:
drop function TEST
go
create function test(@input varchar(100))
returns int
begin atomic
declare @int int default 0;
declare @input_lenght int default 0;
set @input_lenght = length(@input);
while @input_lenght <> 0 do
if ( substr(@input,length(@input) - @input_lenght +1,1) in ('0','1','2','3','4','5','6','7','8','9') ) then
set @int = @int + 0;
elseif ( substr(@input,length(@input) - @input_lenght +1,1) in ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')) then
set @int = @int - 1;
end if;
set @input_lenght = @input_lenght -1;
end while;
if ( @int = 0 or @int = -1* length(@input)) then --- 如果累积为0全是数字;如果累积正好是-1乘以长度则正好全是字段
return 0;
else
return 1;
end if;
end
go
select test ('123456') from sysibm.al 结果是 0
select test ('123b456a') from sysibm.al 结果是 1
select test ('abcdefg') from sysibm.al 结果是 0
H. 请问 SQL 统计过滤 怎么写啊
店铺表自 ecm 主键 ecm_id
商品表 ecm_goods 主键 good_id 店铺id ecm_id
select count(a.ecm_id) from ecm a left join ecm_goods b on a.ecm_id=b.ecm_id group by a.ecm_id having count(b.good_id)>3
I. sql语句里 where条件中怎么把带有字母的结果过滤掉
SQL2000以上的话,就用正则吧
应该是 SELECT * FROM 表名 WHERE REGEXP_INSTR(列名, '[a-z]')=0
J. 想要清除Mysql一个字段里所有的英文、数字、和半角符号,如何操作,只留里面的中文汉字
$str='asdkasd54sd8s788s78dsis爱hi个股';
$str=preg_replace('/d*w*/','',$str);
echo$str;
不过这是先处理好再发送sql语句
尽量少在数据库里做运算,毕竟数专据库主要属功能是存储