Print Page | Close Window

Find field containing character

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8686
Printed Date: 01 April 2026 at 1:12am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Find field containing character
Posted By: pedalcars
Subject: Find field containing character
Date Posted: 08 January 2004 at 10:36am


Is it possible to do something along the lines of the

Mid(stringToExamin, [start_position>, [number_of_characters>) = [Condition_character>

expression in a strSQL statement?

Currently I have along the lines of:

strSQL = "SELECT tblTable.* FROM tblTable;"

'Then having opened the connection and running through have:
If Mid(rs("permissions"), lngAccessLevel, 1) = 1 Then

'Display record

End If

'movenext, loop, etc.

Where tblTable.permissions is a text string (eg, 1101) and lngAccessLevel is the user's status (eg, 1, 2, 3 or 4).

So a level 3 user wont see that record, but others will.

Is it possible to apply the same conditions in the strSQL statement instead, to filter out records the user can't see, rather than bringing them back only to ignore them?

Something like (in concept):

strSQL = "SELECT tblTable.* FROM tblTable WHERE Mid(tblTable.permissions, lngAccessLevel, 1) = 1;"

(which doesn't work - doesn't bring back and errors but doesn't show any records either, even though it "should")

Ta



-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels




Replies:
Posted By: aalavar
Date Posted: 08 January 2004 at 10:47am

Let's say your permissions are always 4 characters, let's also say you want to obtain records with the character '1' in the 2nd slot... ie it would retrieve 0100, but not 1011.  I think this will work:

select * from tbleTable where permissions like '_1__'



Posted By: pedalcars
Date Posted: 08 January 2004 at 11:27am

Thanks - I went to try this and then found my version *does* work - when you specify the correct field in the strSQL expression and not an entirely different one!

D'oH!

I feel a bit  stoopid...



-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels



Posted By: aalavar
Date Posted: 08 January 2004 at 12:47pm

Well sure don't use my answers!

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net