日期:2014-05-16 浏览次数:20820 次
select t.* from tbuser t where substr(t.name,0,3) like 'aa%';
WITH t AS ( SELECT 1 ID,'aa11' NAME,'t1' INFO FROM dual UNION ALL SELECT 2,'aa22', 't1' FROM dual UNION ALL SELECT 3, 'bb33', 't2' FROM dual UNION ALL SELECT 4, 'bb44', 't2' FROM dual UNION ALL SELECT 5, 'cc55', 't3' FROM dual UNION ALL SELECT 6, 'cc66', 't3' FROM dual UNION ALL SELECT 7, 'cs2', 'b' FROM dual UNION ALL SELECT 8, 'ct5', 'b' FROM dual UNION ALL SELECT 9, 'xw6', 'b' FROM dual UNION ALL SELECT 10, '12sre', 'b' FROM dual ) SELECT * FROM t WHERE NAME LIKE 'aa%' OR NAME LIKE 'bb%' OR NAME LIKE 'cc%' ORDER BY id; ID NAME INFO 1 aa11 t1 2 aa22 t1 3 bb33 t2 4 bb44 t2 5 cc55 t3 6 cc66 t3
------解决方案--------------------
select t.* from tbuser t where upper(substr(t.name,0,1))=upper(substr(t.name,1,2));