Results 1 to 11 of 11

Thread: Select Brackets

  1. #1
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Smile Unanswered: Select Brackets

    I have data which are enclosed in brackets [] stored in a table something like that

    Filed contents
    "[Menu 1], 150"
    "140, 60"
    "[Menu 2], 245"
    "[Menu 3], 40"
    "No Menu, 33"

    How could I select those records with the brackets

    SELECT * FROM thisTable WHER thisField LIKE "*[*"
    yields an error

  2. #2
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100
    SELECT * FROM thisTable WHER thisField LIKE "*[*"
    yields an error [/QUOTE]

    Hello Hambakka,
    I don't know if this is the problem: in the sentence you copied the keyword WHERE is not well written. There is an E missing. If it is not that, try using doube [, like: "[[xxxxx]]".

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by pipeio
    SELECT * FROM thisTable WHER thisField LIKE "*[*"
    yields an error
    Thank you for your reply, I forgot only the E in the WHEREclause, but that was not the problem.
    The brackets [] has a special meaning in the Query when you make a prameter query you use them. And there form ACCE$$ says missing charachter because it expects the closing bracket "]". If you use LIKE "*[]*" it will list the whole table content.

    If you use Like "*(*" it functions and shows those with rond Bracketes

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    Thank you for your reply, I forgot only the E in the WHEREclause, but that was not the problem.
    The brackets [] has a special meaning in the Query when you make a prameter query you use them. And there form ACCE$$ says missing charachter because it expects the closing bracket "]". If you use LIKE "*[]*" it will list the whole table content.

    If you use Like "*(*" it functions and shows those with rond Bracketes
    Hammy,

    Try what pipio was saying: Escape the left bracket ... Ex: LIKE "*\[*" -or- try doing using the CHR() route ... LIKE '*" & Chr(XXX) & "* ... I'll try this myself ...

    Oh, BTW, how do you like not being a Grand Poobah anymore?

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by M Owen
    Hammy,

    Try what pipio was saying: Escape the left bracket ... Ex: LIKE "*\[*" -or- try doing using the CHR() route ... LIKE '*" & Chr(XXX) & "* ... I'll try this myself ...

    Oh, BTW, how do you like not being a Grand Poobah anymore?
    I tried the first one, but it comes
    Invalid pattern String because it waits for the closing bracket.


    Owen, your are not Grand Poobah any more, inspite you have more partcipation than me. But that is ACCE$$ life

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    I tried the first one, but it comes
    Invalid pattern String because it waits for the closing bracket.


    Owen, your are not Grand Poobah any more, inspite you have more partcipation than me. But that is ACCE$$ life
    I know ... But back to your issue ... That crap I just suggested won't work (as you know) ... Try this:

    SELECT Test.Test
    FROM Test
    WHERE (((InStr([Test],'['))>0));

    It does.

    - Mike

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Now I tried Like "*" & Chr(91) & "*" but still in vain.

  8. #8
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    Now I tried Like "*" & Chr(91) & "*" but still in vain.
    Barking up the wrong tree Hammy ... Check my post.

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by M Owen
    I know ... But back to your issue ... That crap I just suggested won't work (as you know) ... Try this:

    SELECT Test.Test
    FROM Test
    WHERE (((InStr([Test],'['))>0));

    It does.

    - Mike
    That is right, because you don't use here LIKE
    It must function
    Thanks

  10. #10
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by hammbakka
    That is right, because you don't use here LIKE
    It must function
    Thanks
    Now in order for you to get the brackets AND say "Menu 1" you'll need to do both: Instr and LIKE ...

    ... Instr(Test,'[') >0) AND ( LIKE '*Menu 1*' ) ...

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Talking

    Thats great, it functions here because you used a combination of
    INSTR and LIKE. That is very good idea.

    Thanks M. Owen

Posting Permissions

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