Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - regular expression sql question
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

regular expression sql question

 Post Reply Post Reply
Author
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Topic: regular expression sql question
    Posted: 19 November 2003 at 9:15pm
My system is about directory

I managed to query according to which 2 alphabetic user select.

sql = "Select * FROM customer WHERE companyname LIKE '" & strAlpha1 & "%' "
sql = sql & "OR companyname LIKE '" & strAlpha2 & "%' "
sql = sql & "ORDER BY companyname"
But the problem I face is those companys which are not start with alphabetic like 333 Sdn Bhd, _3COM Limited or etc. I know I can use NOT LIKE but anyway other way besides that because if I use NOT LIKE one by one like:

sql = "Select * FROM customer WHERE companyname NOT LIKE 'A%' "
sql = sql & "OR companyname NOT LIKE 'B%' "
sql = sql & "ORDER BY companyname"

Then I need to repeat it for 26 times since there are 26 alphabetic.

Thanks.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2003 at 9:43pm
You could use the ASCII function with the lowercase function like this

select * from customer where ASCII(LCASE(left(companyname,1))) not between 97 and 122 order by companyname

This will return everything that begins with a non-alpha character as the ASCII number for all the alphabetic lower case characters lies between 97 (a) and 122 (z), inclusive.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2003 at 9:44pm
That assumes you use SQL Server, I'm not sure about Access as I rarely use it.
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Posted: 19 November 2003 at 11:13pm

I tried and it says there

Microsoft JET Database Engine (0x80040E14)
Undefined function 'ASCII' in expression.

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2003 at 1:23am
Originally posted by ljamal ljamal wrote:

That assumes you use SQL Server, I'm not sure about Access as I rarely use it.


As I said above ...
Your error means that the ASCII function is not supported in Access. But since you didn't look it up I guess, I will for you....


The ASCII function in Access is ASC, if you replace ASCII with ASC in the SQL statement above it should work for you. I even tested it with the ASC function in Access, so it does work.

In the future if you are not willing to do the extra legwork when someone points you in the right direction, just hire someone to do it for you.
Back to Top
ngaisteve1 View Drop Down
Groupie
Groupie
Avatar

Joined: 26 December 2002
Location: Malaysia
Status: Offline
Points: 169
Post Options Post Options   Thanks (0) Thanks(0)   Quote ngaisteve1 Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2003 at 2:22am

I'm sorry. I will put extra effort in the future. Thanks a lot. It works.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.