开发者

mysql query fetch all records from a coloumns whoes first 3 letters are alpha(charachert)

开发者_开发技巧
mytable
-------
addressColoumn
1 street
2 street
my address
your address

select address from mytable where addressColoumn= (first 3 character as alpha(character))

so it should return two records

my address
your address

what will be the query?


From your example I'm guessing you mean A-Z, in caps or lowercase, and/or space.

For SQL Server:

where addressColoumn like '[a-z ][a-z ][a-z ]%'

For MySQL:

where addressColoumn REGEXP '^[a-zA-Z ][a-zA-Z ][a-zA-Z ]'

For Oracle:

where regexp_like (addressColoumn, '^[a-zA-Z ][a-zA-Z ][a-zA-Z ]')

Of course, you can also reverse the condition, and check for a numeric first character. Should be easy to adopt the above snippets for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜