help with Selecting Post Codes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • stephen.layton@btinternet.REMOVESPAMcom

    help with Selecting Post Codes

    I have a table containing names and addresses called tblNames and
    constructed as below:

    CREATE TABLE tblnames (
    strNameReferenc e varchar(6) NOT NULL default '',
    strSurname varchar(35) default NULL,
    strSchool varchar(75) default NULL,
    strTitle varchar(25) default NULL,
    strPassword varchar(15) default NULL,
    strPostCode varchar(15) default NULL,
    strEmail varchar(55) default NULL,
    strPasswordHint varchar(35) default NULL,
    PRIMARY KEY (strNameReferen ce),
    KEY strSurname (strSurname,str School,strTitle ),
    KEY strPostCode (strPostCode)
    ) TYPE=MyISAM COMMENT='Names Table';

    The UK Post Code goes on the lines of "CB7 7TS" with a space between the
    two parts of the post code.

    If the following SELECT statement is used:

    SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30

    Then MYsql returns no records but no errors either and PHPMYAdmin states
    that:

    "Your SQL-query has been executed successfully"

    Any help will be appreciated.

    Thank you.
    Stephen Layton




  • Aggro

    #2
    Re: help with Selecting Post Codes

    stephen.layton@ btinternet.REMOVESPAMcom wrote:
    [color=blue]
    > I have a table containing names and addresses called tblNames and
    > constructed as below:[/color]

    There is nothing wrong with the table or with the query. Only reason why
    you would get zero rows is that you don't have a row in your table where
    strPostCode is 'CB4 3DZ'.

    I tested it like this:

    # insert one test row to table
    insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');

    # select rows where strPostCode matches
    SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;

    Comment

    • Aggro

      #3
      Re: help with Selecting Post Codes

      stephen.layton@ btinternet.REMOVESPAMcom wrote:
      [color=blue]
      > I have a table containing names and addresses called tblNames and
      > constructed as below:[/color]

      There is nothing wrong with the table or with the query. Only reason why
      you would get zero rows is that you don't have a row in your table where
      strPostCode is 'CB4 3DZ'.

      I tested it like this:

      # insert one test row to table
      insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');

      # select rows where strPostCode matches
      SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;

      Comment

      • Stephen Layton

        #4
        Re: help with Selecting Post Codes

        Aggro

        Many thanks for your reply following which, I have checked my Access
        Code which takes the Access table and transfers it to a comma separated
        text file. I've just found that it was adding a separate space in the
        Post Code ... so it did not find the required field.

        Thank you for your help..

        In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
        <spammerdream@y ahoo.com> writes[color=blue]
        >[color=green]
        >> I have a table containing names and addresses called tblNames and
        >> constructed as below:[/color]
        >
        >There is nothing wrong with the table or with the query. Only reason
        >why you would get zero rows is that you don't have a row in your table
        >where strPostCode is 'CB4 3DZ'.
        >
        >I tested it like this:
        >
        ># insert one test row to table
        >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
        >
        ># select rows where strPostCode matches
        >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]

        Stephen Layton


        Comment

        • Stephen Layton

          #5
          Re: help with Selecting Post Codes

          Aggro

          Many thanks for your reply following which, I have checked my Access
          Code which takes the Access table and transfers it to a comma separated
          text file. I've just found that it was adding a separate space in the
          Post Code ... so it did not find the required field.

          Thank you for your help..

          In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
          <spammerdream@y ahoo.com> writes[color=blue]
          >[color=green]
          >> I have a table containing names and addresses called tblNames and
          >> constructed as below:[/color]
          >
          >There is nothing wrong with the table or with the query. Only reason
          >why you would get zero rows is that you don't have a row in your table
          >where strPostCode is 'CB4 3DZ'.
          >
          >I tested it like this:
          >
          ># insert one test row to table
          >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
          >
          ># select rows where strPostCode matches
          >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]

          Stephen Layton


          Comment

          • Khazret Sapenov

            #6
            Re: help with Selecting Post Codes

            You can use TRIM() to process input (or just update ) as well and change
            postal code field length to 6.
            It will save memory a bit.

            Khazret Sapenov


            "Stephen Layton" <stephen@stephe nlayton.org> wrote in message
            news:1wOCyyAvMr kAFwvf@stephenl ayton.org...[color=blue]
            > Aggro
            >
            > Many thanks for your reply following which, I have checked my Access
            > Code which takes the Access table and transfers it to a comma separated
            > text file. I've just found that it was adding a separate space in the
            > Post Code ... so it did not find the required field.
            >
            > Thank you for your help..
            >
            > In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
            > <spammerdream@y ahoo.com> writes[color=green]
            > >[color=darkred]
            > >> I have a table containing names and addresses called tblNames and
            > >> constructed as below:[/color]
            > >
            > >There is nothing wrong with the table or with the query. Only reason
            > >why you would get zero rows is that you don't have a row in your table
            > >where strPostCode is 'CB4 3DZ'.
            > >
            > >I tested it like this:
            > >
            > ># insert one test row to table
            > >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
            > >
            > ># select rows where strPostCode matches
            > >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]
            >
            > Stephen Layton
            >
            >[/color]


            Comment

            • Khazret Sapenov

              #7
              Re: help with Selecting Post Codes

              You can use TRIM() to process input (or just update ) as well and change
              postal code field length to 6.
              It will save memory a bit.

              Khazret Sapenov


              "Stephen Layton" <stephen@stephe nlayton.org> wrote in message
              news:1wOCyyAvMr kAFwvf@stephenl ayton.org...[color=blue]
              > Aggro
              >
              > Many thanks for your reply following which, I have checked my Access
              > Code which takes the Access table and transfers it to a comma separated
              > text file. I've just found that it was adding a separate space in the
              > Post Code ... so it did not find the required field.
              >
              > Thank you for your help..
              >
              > In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
              > <spammerdream@y ahoo.com> writes[color=green]
              > >[color=darkred]
              > >> I have a table containing names and addresses called tblNames and
              > >> constructed as below:[/color]
              > >
              > >There is nothing wrong with the table or with the query. Only reason
              > >why you would get zero rows is that you don't have a row in your table
              > >where strPostCode is 'CB4 3DZ'.
              > >
              > >I tested it like this:
              > >
              > ># insert one test row to table
              > >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
              > >
              > ># select rows where strPostCode matches
              > >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]
              >
              > Stephen Layton
              >
              >[/color]


              Comment

              • Khazret Sapenov

                #8
                Re: help with Selecting Post Codes

                You can use TRIM() to process input (or just update ) as well and change
                postal code field length to 6.
                It will save memory a bit.

                Khazret Sapenov


                "Stephen Layton" <stephen@stephe nlayton.org> wrote in message
                news:1wOCyyAvMr kAFwvf@stephenl ayton.org...[color=blue]
                > Aggro
                >
                > Many thanks for your reply following which, I have checked my Access
                > Code which takes the Access table and transfers it to a comma separated
                > text file. I've just found that it was adding a separate space in the
                > Post Code ... so it did not find the required field.
                >
                > Thank you for your help..
                >
                > In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
                > <spammerdream@y ahoo.com> writes[color=green]
                > >[color=darkred]
                > >> I have a table containing names and addresses called tblNames and
                > >> constructed as below:[/color]
                > >
                > >There is nothing wrong with the table or with the query. Only reason
                > >why you would get zero rows is that you don't have a row in your table
                > >where strPostCode is 'CB4 3DZ'.
                > >
                > >I tested it like this:
                > >
                > ># insert one test row to table
                > >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
                > >
                > ># select rows where strPostCode matches
                > >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]
                >
                > Stephen Layton
                >
                >[/color]


                Comment

                • Khazret Sapenov

                  #9
                  Re: help with Selecting Post Codes

                  You can use TRIM() to process input (or just update ) as well and change
                  postal code field length to 6.
                  It will save memory a bit.

                  Khazret Sapenov


                  "Stephen Layton" <stephen@stephe nlayton.org> wrote in message
                  news:1wOCyyAvMr kAFwvf@stephenl ayton.org...[color=blue]
                  > Aggro
                  >
                  > Many thanks for your reply following which, I have checked my Access
                  > Code which takes the Access table and transfers it to a comma separated
                  > text file. I've just found that it was adding a separate space in the
                  > Post Code ... so it did not find the required field.
                  >
                  > Thank you for your help..
                  >
                  > In message <q%xkc.704$9E3. 279@read3.inet. fi>, Aggro
                  > <spammerdream@y ahoo.com> writes[color=green]
                  > >[color=darkred]
                  > >> I have a table containing names and addresses called tblNames and
                  > >> constructed as below:[/color]
                  > >
                  > >There is nothing wrong with the table or with the query. Only reason
                  > >why you would get zero rows is that you don't have a row in your table
                  > >where strPostCode is 'CB4 3DZ'.
                  > >
                  > >I tested it like this:
                  > >
                  > ># insert one test row to table
                  > >insert into tblnames values('x','x', 'x','x','x','CB 4 3DZ','x','x');
                  > >
                  > ># select rows where strPostCode matches
                  > >SELECT * FROM `tblnames` WHERE strPostCode like 'CB4 3DZ' LIMIT 0, 30;[/color]
                  >
                  > Stephen Layton
                  >
                  >[/color]


                  Comment

                  Working...