Looking for space char in DataBase

Hello.

I have this strings in my database table:
"1234567890"
"123 456 789 0"

I want to find only the "456" from the second string (with spaces before and after)

Tried:
select * from myTable Where colName like '% 456 %'
or
select * from myTable Where colName like '%'+space(1)+'456'+space(1)+'%'
or
select * from myTable Where colName like '%'+char(32)+'456'+char(32)+'%'


and nothing.
From the Query Analyzer it's OK but not from my application (VB6).
What could be the resone ?

thanks


Comments

  • : Hello.
    :
    : I have this strings in my database table:
    : "1234567890"
    : "123 456 789 0"
    :
    : I want to find only the "456" from the second string (with spaces before and after)
    :
    : Tried:
    : select * from myTable Where colName like '% 456 %'
    : or
    : select * from myTable Where colName like '%'+space(1)+'456'+space(1)+'%'
    : or
    : select * from myTable Where colName like '%'+char(32)+'456'+char(32)+'%'
    :
    :
    : and nothing.
    : From the Query Analyzer it's OK but not from my application (VB6).
    : What could be the resone ?
    :
    : thanks
    :
    :
    :
    have you tried
    strSQL = "select * from myTable Where colName like '%'" & " " & "'456'" & " " & "'%'"?
    If this won't work, you should see about writing either a function or a stored proc to parse the string using the space as a delimiter and search for that particular string.
    hope this helps.



    To ERR is human, but to really f**k something up requires a computer...

  • : strSQL = "select * from myTable Where colName like '%'" & " " & "'456'" & " " & "'%'"?

    That will resolve to the following string:

    select * from myTable Where colName like '%' '456' '%'

    ... which is not valid SQL.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]


  • : That will resolve to the following string:
    :
    : select * from myTable Where colName like '%' '456' '%'
    :
    : ... which is not valid SQL.
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    : [code]
    : $ select * from users where clue > 0
    : no rows returned
    : [/code]
    :
    :


    "select * from myTable Where colName like '%" & " " & "456" & " " & "%'"?

    okay, now this will give the string
    select * from mytable where colname like '% 456 %'
    is that better?
    hey, everyone makes mistakes, and I am trying to spend my time helping.
    Now, is this better?
    To ERR is human, but to really f**k something up requires a computer...

  • : : Hello.
    : :
    : : I have this strings in my database table:
    : : "1234567890"
    : : "123 456 789 0"
    : :
    : : I want to find only the "456" from the second string (with spaces before and after)
    : :
    : : Tried:
    : : select * from myTable Where colName like '% 456 %'
    : : or
    : : select * from myTable Where colName like '%'+space(1)+'456'+space(1)+'%'
    : : or
    : : select * from myTable Where colName like '%'+char(32)+'456'+char(32)+'%'
    : :
    : :
    : : and nothing.
    : : From the Query Analyzer it's OK but not from my application (VB6).
    : : What could be the resone ?
    : :
    : : thanks
    : :
    : :
    : :
    : have you tried
    : strSQL = "select * from myTable Where colName like '%'" & " " & "'456'" & " " & "'%'"?
    : If this won't work, you should see about writing either a function or a stored proc to parse the string using the space as a delimiter and search for that particular string.
    : hope this helps.
    :
    :
    :
    : To ERR is human, but to really f**k something up requires a computer...
    :
    :


    Thanks...
    strSQL = "select * from myTable Where colName like '%'" & " " & "'456'" & " " & "'%'" ---> works great
  • : Thanks...
    : strSQL = "select * from myTable Where colName like '%'" & " " & "'456'" & " " & "'%'" ---> works great

    Seriously? What kind of bizarro database are you using?


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories