Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Cannot Find Rows With % character in Text Fields with Access SQL

Cannot Find Rows With % character in Text Fields with Access SQL

Scheduled Pinned Locked Moved Database
databasesalesjsonquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnBlocker
    wrote on last edited by
    #1

    I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s. I have a table named "Foo", with two rows: Type as text, SubType as text, with two rows of values: "Sales Tax (%)", "NY" "Sales Tax (%)", PA" When I execute the following:

    SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'

    I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)" But when I execute:

    SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

    No rows are returned Even if I omit the parenthesis around the % sign, it does not find the rows. Is there something odd I am doing wrong, perhaps specific to Access SQL?

    J Richard DeemingR J F 4 Replies Last reply
    0
    • J JohnBlocker

      I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s. I have a table named "Foo", with two rows: Type as text, SubType as text, with two rows of values: "Sales Tax (%)", "NY" "Sales Tax (%)", PA" When I execute the following:

      SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'

      I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)" But when I execute:

      SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

      No rows are returned Even if I omit the parenthesis around the % sign, it does not find the rows. Is there something odd I am doing wrong, perhaps specific to Access SQL?

      J Offline
      J Offline
      Jorgen Andersson
      wrote on last edited by
      #2

      <edit>move on, nothing to see here except the proofs of to little sleep.</edit> Access isn't SQLServer. You're not supposed to use brackets either. I would strongly recommend renaming the offending fields. More info here[^]. I especially like this part: "However, if you do use the special characters, you may experience unexpected errors."

      Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

      J 1 Reply Last reply
      0
      • J Jorgen Andersson

        <edit>move on, nothing to see here except the proofs of to little sleep.</edit> Access isn't SQLServer. You're not supposed to use brackets either. I would strongly recommend renaming the offending fields. More info here[^]. I especially like this part: "However, if you do use the special characters, you may experience unexpected errors."

        Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

        J Offline
        J Offline
        JohnBlocker
        wrote on last edited by
        #3

        I am not sure I understand. The % character does not appear in any field names, or table names. The data type of both fields, named "Type" and "SubType" are text, and that text data can contain a % character as part of whatever text the user chooses to enter into the field, along with other special characters. (I have an application where I prompt the user to enter a text value for the Type and SubType fields, and I save that text into those fields as a new row. The problem I have is that the user can enter a % as part of their user-entered text, and I need to be able to search on text field data for a % character they may have entered; I can put brackets around all other special characters when building my query and they are found fine, but the % just doesn't work for some reason when used in an = query.

        J 1 Reply Last reply
        0
        • J JohnBlocker

          I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s. I have a table named "Foo", with two rows: Type as text, SubType as text, with two rows of values: "Sales Tax (%)", "NY" "Sales Tax (%)", PA" When I execute the following:

          SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'

          I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)" But when I execute:

          SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

          No rows are returned Even if I omit the parenthesis around the % sign, it does not find the rows. Is there something odd I am doing wrong, perhaps specific to Access SQL?

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          JohnBlocker wrote:

          Even if I omit the parenthesis around the % sign, it does not find the rows.

          So this:

          SELECT * From Foo WHERE Type = 'Sales Tax (%)'

          returns nothing?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          1 Reply Last reply
          0
          • J JohnBlocker

            I am not sure I understand. The % character does not appear in any field names, or table names. The data type of both fields, named "Type" and "SubType" are text, and that text data can contain a % character as part of whatever text the user chooses to enter into the field, along with other special characters. (I have an application where I prompt the user to enter a text value for the Type and SubType fields, and I save that text into those fields as a new row. The problem I have is that the user can enter a % as part of their user-entered text, and I need to be able to search on text field data for a % character they may have entered; I can put brackets around all other special characters when building my query and they are found fine, but the % just doesn't work for some reason when used in an = query.

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #5

            My bad, I think my brain went to sleep before the rest of me did.

            Be excellent to each other. And... PARTY ON, DUDES! Abraham Lincoln

            1 Reply Last reply
            0
            • J JohnBlocker

              I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s. I have a table named "Foo", with two rows: Type as text, SubType as text, with two rows of values: "Sales Tax (%)", "NY" "Sales Tax (%)", PA" When I execute the following:

              SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'

              I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)" But when I execute:

              SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

              No rows are returned Even if I omit the parenthesis around the % sign, it does not find the rows. Is there something odd I am doing wrong, perhaps specific to Access SQL?

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              JohnBlocker wrote:

              When parsing user input that has SQL reserved characters

              Parsing how? What application/language are you doing this in?

              1 Reply Last reply
              0
              • J JohnBlocker

                I am using an Access 2000 database file. When parsing user input that has SQL reserved characters, I put [] around any reserved characters I find. This works fine, except when dealing with %s. I have a table named "Foo", with two rows: Type as text, SubType as text, with two rows of values: "Sales Tax (%)", "NY" "Sales Tax (%)", PA" When I execute the following:

                SELECT * From Foo WHERE Type LIKE '%Sales Tax ([%])%'

                I get the rows returned I expect, where the row has a value in the Type column of "Sales Tax (%)" But when I execute:

                SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

                No rows are returned Even if I omit the parenthesis around the % sign, it does not find the rows. Is there something odd I am doing wrong, perhaps specific to Access SQL?

                F Offline
                F Offline
                Fabricio Dos Santos Antunes
                wrote on last edited by
                #7

                This could be an odd question, but, you tried

                Quote:

                SELECT * From Foo WHERE Type = 'Sales Tax ([%])'

                Cause, when your using '=' command, means that is HAS to be egual.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups