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
----------
支持
[解决办法]
顶