求一SQL查找语句
字段中有如下内容
23233-34
1121-34A
4343-3455-34B
G332-34C
HGF-231-45A
HGD-P1-P2-54B
kkj-weweew-34A
KLI-O2-P4-54D
HUI-we-rre-34B
要求条件:按最后结尾字符仅仅输入:34
则得到如下的记录 (即遇上最后一位如果是字母a-z 或A-Z的则判断最后结尾字符是排除这些字母来计算)
23233-34
1121-34A
4343-3455-34B
G332-34C
kkj-weweew-34A
HUI-we-rre-34B
[解决办法]
--> 测试数据:[tb]IF OBJECT_ID('[tb]') IS NOT NULL DROP TABLE [tb]GO CREATE TABLE [tb]([name] VARCHAR(14))INSERT [tb]SELECT '23233-34' UNION ALLSELECT '1121-34A' UNION ALLSELECT '4343-3455-34B' UNION ALLSELECT 'G332-34C' UNION ALLSELECT 'HGF-231-45A' UNION ALLSELECT 'HGD-P1-P2-54B' UNION ALLSELECT 'kkj-weweew-34A' UNION ALLSELECT 'KLI-O2-P4-54D' UNION ALLSELECT 'HUI-we-rre-34B'--------------开始查询--------------------------SELECT * FROM [tb] WHERE name LIKE '%34' OR name LIKE '%34[a-z]'----------------结果----------------------------/* name--------------23233-341121-34A4343-3455-34BG332-34Ckkj-weweew-34AHUI-we-rre-34B(6 行受影响)*/