SELECT和正则表达式 [英] SELECT and regular expression
本文介绍了SELECT和正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不是MSSQL的大朋友,但我必须做一个查询我已经完成了
mySQL 。
但是我不知道怎么...
我必须从db中选择''user'',其中第一个字母是E或N,第二个是B
或0之后我知道有6或7位数。
我该怎么做?
在mySQL中它会是这样的:
SELECT * FROM`table` WHERE`帐号`regexp''^ [EN] [B0] 123456 $''订购:
`Id`;
提前致谢,
Martin
解决方案
''ORDER BY
`Id`;
提前致谢,
Martin
where(账号如''EB%
或账号如''NB%'')
和(账号如''E0%
或像''N0%''这样的账号。
和len(账户)在6到7之间
-
Tony Rogerson
SQL Server MVP
http:// sqlserverfaq .com - 免费视频教程
" Martin Lukasik" <毫安**** @ milea.pl.i.hate.this.spam>在消息中写道
news:68 ************************** @ ZOO.CO.UK ... < blockquote class =post_quotes>
我不是MSSQL的大朋友,但我必须做一个查询我为
mySQL做了。
但我不知道怎么...
我必须从''db''中选择''user'',其中第一个字母是E或N,第二个是
B或0之后我知道有6或7位数。
我该怎么做?
在mySQL中它会是这样的:
SELECT * FROM`table` WHERE`帐号`regexp''^ [EN] [B0] 123456
''订购者
`Id`;
在此先感谢,
Hi,
I''m not a big friend of MSSQL, but I have to do one query I''ve done for
mySQL.
But I don''t know how...
I have to select ''user'' from ''db'' where first letter is E or N, second is B
or 0 and after that there are 6 or 7 digits I know.
How can I do that?
In mySQL it would be something like:
SELECT * FROM `table` WHERE `account` regexp ''^[EN][B0]123456$'' ORDER BY
`Id`;
Thanks in advance,
Martin
解决方案
'' ORDER BY
`Id`;
Thanks in advance,
Martin
where ( account like ''EB%
or account like ''NB%'' )
and ( account like ''E0%
or account like ''N0%'' )
and len( account ) between 6 and 7
--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"Martin Lukasik" <ma****@milea.pl.i.hate.this.spam> wrote in message
news:68**************************@ZOO.CO.UK...Hi,
I''m not a big friend of MSSQL, but I have to do one query I''ve done for
mySQL.
But I don''t know how...
I have to select ''user'' from ''db'' where first letter is E or N, second is
B or 0 and after that there are 6 or 7 digits I know.
How can I do that?
In mySQL it would be something like:
SELECT * FROM `table` WHERE `account` regexp ''^[EN][B0]123456
'' ORDER BY
`Id`;
Thanks in advance,
Martin
这篇关于SELECT和正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文