PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Getting the value of the given strings-VBForums
Results 1 to 7 of 7

Thread: Getting the value of the given strings

  1. #1

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Resolved [RESOLVED] Getting the value of the given strings

    Hello everyone, I have a problem regarding getting the value of the string. For example I have '345' on my string and on my database I have field of tables that the strings are divisible by 3 like for example 934526345789 and it was stored on my msaccess database. My problem is that I am comparing the strings i have, if it is existing or not but my problem is that on the database field it should be chunk 3 by 3. Like the example I have, it is 934,526,345,789 so only 1 number of 345 is there. But if you observed there is another 345 there but chunk therefore it is not the strings same as what i have on my strings. So if in the database there is 934526, the string that i have that was '345' is not existing to that value because it is 934,526. Could anybody help me to solve this? The query or the syntax on how to get that. Thanks in advance.
    Last edited by shyguyjeff; Jul 19th, 2011 at 05:08 AM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,227

    Re: Getting the value of the given strings

    I presume you are currently using a Like query with % (or *) wildcards to match any amount of characters, in which case just change it to _ (or ?) to indicate a single character, eg:
    Code:
    Like '%345___'
    ..and use multiple copies of that, one for each possible length.

    If you have problems getting it working, show us the code (as you should have done before) and tell us the issue(s).

  3. #3

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: Getting the value of the given strings

    thank for the response si_the_geek.. this is my query..

    vb Code:
    1. CSClass = '123'
    2. strSQL = "SELECT ClassificationCode, ClassCode FROM Classification WHERE ClassificationCode LIKE '" & CSClass.ToString() & "%'"

    My problem to this is that it will just return any series number that contains '123' but that's not what i want. Since the ClassificationCode contained numbers that are divisible by 3, I want to compare it 3 by 3. Like for example '234341235', this number will still display on my grid even i don't want to because If it will chunk it, it will be 234,341,235 so there's no '123' on it.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,227

    Re: Getting the value of the given strings

    Is there a reason that you haven't tried my suggestion?

  5. #5

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: Getting the value of the given strings

    Thanks again si_the_geek.

    it won't work. Maybe i misunderstand for what you have suggested.

    What i did is '%" & CSClass.ToString() & "_'" instead of '" & CSClass.ToString() & "%'

    and use multiple copies of that, one for each possible length
    What did you mean by this? How to do that?

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,227

    Re: Getting the value of the given strings

    Quote Originally Posted by shyguyjeff View Post
    What i did is '%" & CSClass.ToString() & "_'"
    That will match values which have any characters (%), followed by your string, followed by any single character (_).

    To have it followed by any 3 characters, you need 3 _ wildcards as I showed.
    What did you mean by this? How to do that?
    Use multiple Like conditions (one for 3 characters after, one for 6 characters after, ...), joined by OR's.

  7. #7

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: Getting the value of the given strings

    ahhh i see..now i got the point...I will try to do that and i will come back later after resolving this problem. Thanks si_the_geek. Have a nice day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width