Professional Web Applications Themes

distinguish between "-" and "_" - MySQL

Hello, When I run two different SQL requests, they return same result: SELECT part_number, description FROM part WHERE part_number LIKE "000-1_GB-01" and SELECT part_number, description FROM part WHERE part_number LIKE "000-1-GB-01" I expect the first one returns "not found" since there's no "000-1_GB-01" in the part table, only "000-1-GB-01". but both returns "000-1-GB-01". Can anyone please tell me why? where should I go to find the course ? Thanks in advance. Lei...

  1. #1

    Default distinguish between "-" and "_"

    Hello,

    When I run two different SQL requests, they return same result:

    SELECT part_number, description FROM part WHERE part_number LIKE
    "000-1_GB-01"

    and

    SELECT part_number, description FROM part WHERE part_number LIKE
    "000-1-GB-01"

    I expect the first one returns "not found" since there's no
    "000-1_GB-01"
    in the part table, only "000-1-GB-01". but both returns "000-1-GB-01".
    Can anyone please tell me why?
    where should I go to find the course ?
    Thanks in advance.

    Lei

    leileili@hotmail.com Guest

  2. #2

    Default Re: distinguish between "-" and "_"



    Were you aware that _ is a wildcard character, so your first query
    could match "000-1QGB-01"? Solution: if you want a literal _, escape
    it.


    Gordon Guest

  3. #3

    Default Re: distinguish between "-" and "_"

    On May 21, 3:23 pm, org (Gordon Burditt) wrote: 



    >
    > Were you aware that _ is a wildcard character, so your first query
    > could match "000-1QGB-01"? Solution: if you want a literal _, escape
    > it.[/ref]

    I didn't know that. Thanks for your information. -Lei

    leileili@hotmail.com Guest

  4. #4

    Default Re: distinguish between "-" and "_"

    On 21 May, 23:23, org (Gordon Burditt) wrote: 



    >
    > Were you aware that _ is a wildcard character, so your first query
    > could match "000-1QGB-01"? Solution: if you want a literal _, escape
    > it.[/ref]

    And don't use LIKE where it is not needed. In this situation you
    should use =

    Captain Guest

  5. #5

    Default Re: distinguish between "-" and "_"

    On Mon, 21 May 2007 22:23:15 +0000, Gordon Burditt wrote:
     
    >
    > Were you aware that _ is a wildcard character, so your first query
    > could match "000-1QGB-01"? Solution: if you want a literal _, escape
    > it.[/ref]

    The underscore will match any one character.
    The % will match any charcters including none.

    So LIKE "000-1_GB-01"
    will ok "000-1AGB-01"
    or "000-1XGB-01"
    etc A-the underscore matches ANYTHING in this position.


    And LIKE "000-1%GB-01"
    will ok "000-1GB-01"
    or "000-1XGB-01"
    or "000-1XYZGB-01"
    etc A-the percent matches anything that STARTS in
    this position, including nothing.

    Chris


    Christopher Guest

  6. #6

    Default Re: distinguish between "-" and "_"

    Christopher Pomasl wrote: 
    >> Were you aware that _ is a wildcard character, so your first query
    >> could match "000-1QGB-01"? Solution: if you want a literal _, escape
    >> it.[/ref]
    >
    > The underscore will match any one character.
    > The % will match any charcters including none.
    >
    > So LIKE "000-1_GB-01"
    > will ok "000-1AGB-01"
    > or "000-1XGB-01"
    > etc A-the underscore matches ANYTHING in this position.
    >
    >
    > And LIKE "000-1%GB-01"
    > will ok "000-1GB-01"
    > or "000-1XGB-01"
    > or "000-1XYZGB-01"
    > etc A-the percent matches anything that STARTS in
    > this position, including nothing.
    >
    > Chris
    >
    >[/ref]

    Chris,

    To start with, get a handle on database design theory (it's not that
    hard). Google for "database normalization". That should help get you
    started.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  7. #7

    Default Re: distinguish between "-" and "_"

    == Quote from Jerry Stuckle (net)'s article 
    > >
    > > The underscore will match any one character.
    > > The % will match any charcters including none.
    > >
    > > So LIKE "000-1_GB-01"
    > > will ok "000-1AGB-01"
    > > or "000-1XGB-01"
    > > etc A-the underscore matches ANYTHING in this position.
    > >
    > >
    > > And LIKE "000-1%GB-01"
    > > will ok "000-1GB-01"
    > > or "000-1XGB-01"
    > > or "000-1XYZGB-01"
    > > etc A-the percent matches anything that STARTS in
    > > this position, including nothing.
    > >
    > > Chris
    > >
    > >[/ref]
    > Chris,
    > To start with, get a handle on database design theory (it's not that
    > hard). Google for "database normalization". That should help get you
    > started.[/ref]

    here's a good start from mysql's website:

    http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
    --
    POST BY: lark with PHP News Reader
    lark Guest

Similar Threads

  1. Replies: 1
    Last Post: April 24th, 01:27 PM
  2. CFINPUT type="radio" w/ "value" requires "label"
    By Iceborer in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 21st, 06:16 PM
  3. dr("field").toString returns "400.0000" instead of "400"
    By Dan in forum Microsoft SQL / MS SQL Server
    Replies: 5
    Last Post: July 22nd, 05:48 PM
  4. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139