日期:2014-05-18  浏览次数:20449 次

sql语句中WHERE条件的问题
表中有一列,假如 "0141-92 ", "0141-1992 "   这样的值,我要查询出在 "- "后只有两个字符的数据.   即找出   "0141-92 "这样的值.
where条件里如何写?

------解决方案--------------------
表中有一列,假如 "0141-92 ", "0141-1992 " 这样的值,我要查询出在 "- "后只有两个字符的数据. 即找出 "0141-92 "这样的值.
where条件里如何写?

select * from tb where len(substring(col , charindex( '- ',col) + 1 ,len(col) - charindex( '- ',col) - 1)) = 2
------解决方案--------------------
select * from 表 where charindex( '- ',reverse(列))=3

----------
支持
------解决方案--------------------