22,301
社区成员




SELECT 购买商场, CAST(购买商场 AS varbinary(1000)
FROM ***表 WHERE (购买商场 LIKE '%二级%')
SELECT 备注 FROM ***表 WHERE (购买商场 LIKE '%库%')
--看有结果没!没有说明这个“库”字有问题!
SELECT 备注 FROM ***表 WHERE (购买商场 LIKE '%二级库%')
SELECT 备注 FROM ***表 WHERE (购买商场 LIKE '%二级%')
我估计你的二级和库之间有个小空隙。
-- 不好意思,刚才不贴完
set nocount on
--1--
print '建立初始数据表Customer'
create table Customer(id int,uname varchar(10))
insert into Customer
select 1,'Jim' union all
select 2,'Simith' union all
select 3,'uonun'
select * from Customer
--2--
print '建立初始数据表Info'
create table Info(uname varchar(10),phone varchar(11))
insert into Info
select 'JIM','13800000000' union all
select 'Simith','13911111111' union all
select 'uonun','13812345678'
select * from Info
--3--
print '不区分大小写,不区分全半角'
select c.id,c.uname as 'c.uname',i.uname as 'i.uname',i.phone
from Customer as c inner join Info as i
on c.uname = i.uname
--4--
print '区分大小写,不区分全半角'
select c.id,c.uname as 'c.uname',i.uname as 'i.uname',i.phone
from Customer as c inner join Info as i
on c.uname = i.uname
collate Chinese_PRC_CS_AS
--5--
print '不区分大小写,区分全半角'
select c.id,c.uname as 'c.uname',i.uname as 'i.uname',i.phone
from Customer as c inner join Info as i
on c.uname = i.uname
collate Chinese_PRC_CI_AI_WS
--6--
print '区分大小写,区分全半角'
select c.id,c.uname as 'c.uname',i.uname as 'i.uname',i.phone
from Customer as c inner join Info as i
on c.uname = i.uname
collate Chinese_PRC_CS_AI_WS
DROP TABLE Customer
DROP TABLE Info
/*
建立初始数据表Customer
id uname
----------- ----------
1 Jim
2 Simith
3 uonun
建立初始数据表Info
uname phone
---------- -----------
JIM 13800000000
Simith 13911111111
uonun 13812345678
不区分大小写,不区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
1 Jim JIM 13800000000
2 Simith Simith 13911111111
3 uonun uonun 13812345678
区分大小写,不区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
2 Simith Simith 13911111111
3 uonun uonun 13812345678
不区分大小写,区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
1 Jim JIM 13800000000
3 uonun uonun 13812345678
区分大小写,区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
3 uonun uonun 13812345678
*/
on c.uname = i.uname
collate Chinese_PRC_CI_AI_WS
--6--
print '区分大小写,区分全半角'
select c.id,c.uname as 'c.uname',i.uname as 'i.uname',i.phone
from Customer as c inner join Info as i
on c.uname = i.uname
collate Chinese_PRC_CS_AI_WS
DROP TABLE Customer
DROP TABLE Info
/*
建立初始数据表Customer
id uname
----------- ----------
1 Jim
2 Simith
3 uonun
建立初始数据表Info
uname phone
---------- -----------
JIM 13800000000
Simith 13911111111
uonun 13812345678
不区分大小写,不区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
1 Jim JIM 13800000000
2 Simith Simith 13911111111
3 uonun uonun 13812345678
区分大小写,不区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
2 Simith Simith 13911111111
3 uonun uonun 13812345678
不区分大小写,区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
1 Jim JIM 13800000000
3 uonun uonun 13812345678
区分大小写,区分全半角
id c.uname i.uname phone
----------- ---------- ---------- -----------
3 uonun uonun 13812345678
*/