Loading ...
Sorry, an error occurred while loading the content.

Re: column name -> table name

Expand Messages
  • tekio_pr
    ... I forget give sqlquery example: select table1.*,table2.* from table1,table2 where table1.id=table2.t1_id
    Message 1 of 3 , Jan 1, 2004
    • 0 Attachment
      --- In firebird-support@yahoogroups.com, "tekio_pr" <tekio@k...>
      wrote:
      > Hi
      >
      > I have column name and column index.
      > How to identify table name belongs to this column?
      > delphi6 + zeos6.0.12 + firebird1.5
      >
      > (sorry for my english:-)
      > tekio@k...

      I forget give sqlquery example:
      select table1.*,table2.* from table1,table2
      where table1.id=table2.t1_id
    • Lester Caine
      ... Using .* is bad practice, you should list just the columns you need when building the query. SELECT TABLE1.ID , TABLE1.F1 , TABLE1.F2 , TABLE1.F3 ,
      Message 2 of 3 , Jan 1, 2004
      • 0 Attachment
        > I forget give sqlquery example:
        > select table1.*,table2.* from table1,table2
        > where table1.id=table2.t1_id

        Using .* is bad practice, you should list just the columns
        you need when building the query.

        SELECT TABLE1.ID
        , TABLE1.F1
        , TABLE1.F2
        , TABLE1.F3
        , TABLE2.ID
        , TABLE2.F1
        , TABLE2.F2
        , TABLE2.F3
        FROM TABLE1
        JOIN TABLE2
        ON TABLE2.ID = TABLE1.ID

        Once you have this, you can either
        ORDER BY TABLE1.F1
        or
        ORDER BY 2
        Where 2 is the second column. Using .* means that you do not
        know what order the columns are in, and this can change, for
        example if more columns are added to TABLE1

        --
        Lester Caine
        -----------------------------
        L.S.Caine Electronic Services
      Your message has been successfully submitted and would be delivered to recipients shortly.