mysql_query where name unknown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oak Hall

    mysql_query where name unknown

    I have a several tables the primary index field name in different in each
    one, how do I query with a 'where "column 1" = 3' if I do not know the name
    of that column only that it is the first field?? Thanks
    Oak


  • Oli Filth

    #2
    Re: mysql_query where name unknown

    Oak Hall said the following on 27/09/2005 18:33:[color=blue]
    > I have a several tables the primary index field name in different in each
    > one, how do I query with a 'where "column 1" = 3' if I do not know the name
    > of that column only that it is the first field?? Thanks
    > Oak
    >
    >[/color]

    Execute the following MySQL statement:

    SHOW COLUMNS FROM table

    (where 'table' is the name of the table in question).

    The result-set will be a list of the columns from that table.

    --
    Oli

    Comment

    • Oak Hall

      #3
      Re: mysql_query where name unknown

      thanks will use that

      "Oli Filth" <catch@olifilth .co.uk> wrote in message
      news:nuf_e.624$ Nv6.443@newsfe6-win.ntli.net...[color=blue]
      > Oak Hall said the following on 27/09/2005 18:33:[color=green]
      >> I have a several tables the primary index field name in different in each
      >> one, how do I query with a 'where "column 1" = 3' if I do not know the
      >> name of that column only that it is the first field?? Thanks
      >> Oak
      >>
      >>[/color]
      >
      > Execute the following MySQL statement:
      >
      > SHOW COLUMNS FROM table
      >
      > (where 'table' is the name of the table in question).
      >
      > The result-set will be a list of the columns from that table.
      >
      > --
      > Oli[/color]


      Comment

      • Dikkie Dik

        #4
        Re: mysql_query where name unknown

        Oak Hall wrote:[color=blue]
        > I have a several tables the primary index field name in different in each
        > one, how do I query with a 'where "column 1" = 3' if I do not know the name
        > of that column only that it is the first field?? Thanks
        > Oak
        >
        >[/color]
        In the special case you would read the entire record, you could also use
        the HANDLER statement.
        HANDLER <table name> OPEN AS <handle name>;
        HANDLER <handle name> READ `PRIMARY`=3;

        It is wise to close the handle later with HANDLER <handle name> CLOSE;

        Best regards

        Comment

        • Colin Fine

          #5
          Re: mysql_query where name unknown

          Oak Hall wrote:[color=blue]
          > I have a several tables the primary index field name in different in each
          > one, how do I query with a 'where "column 1" = 3' if I do not know the name
          > of that column only that it is the first field?? Thanks
          > Oak
          >
          >[/color]
          Does SQL (or MySQL) specify that the order of columns is a table is
          invariant?

          Colin

          Comment

          Working...