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語句
盡量少在資料庫里做運算,畢竟數專據庫主要屬功能是存儲