Select from two tables

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Select from two tables

    after selecting from two table like so-

    select table1.column, table2.column from table1, table2 ...

    What is the correct syntax to access the individual table data?

    With one table I would normally just use- rs("column")

    TIA


    Taper Litwater Guest

  2. Similar Questions and Discussions

    1. Select Sum acrross tables
      Hi, I have few different sales tables and I would like to know how I can write qeury that produces following results.. Tables=(sale.accom,...
    2. Select accoss 2 tables
      Hi everyone, A bit stuck....and I will try to explain well. I have 2 tables in a MySQL database. In PHP I am trying to find the first...
    3. MySQL Q - SELECT with 2 tables
      Message-ID: <acad69df.0309030913.330334ac@posting.google.com> from Marc contained the following: I don't think you've quite got the hang of...
    4. SELECT DISTINCT from two tables
      Hi I have two table which are related: table1 holds personellinformation table2 holds nodeInformation The nodes in table2 can have a...
    5. Select quantity from 2 tables
      I have 2 tables: table1: country1 quantity1 idProduct1 table2: country2 quantity2 idProduct2 Now I have to get the...
  3. #2

    Default Re: Select from two tables

    same thing. If you have mitiple columns with the same name select by using
    rs(x) where x is the index of the column in the select.

    Mike

    "Taper Litwater" <Litwater@NOSPAM.com> wrote in message
    news:ulF9szLnDHA.2592@TK2MSFTNGP10.phx.gbl...
    > after selecting from two table like so-
    >
    > select table1.column, table2.column from table1, table2 ...
    >
    > What is the correct syntax to access the individual table data?
    >
    > With one table I would normally just use- rs("column")
    >
    > TIA
    >
    >

    Mike Guest

  4. #3

    Default Re: Select from two tables

    On Mon, 27 Oct 2003 11:03:08 -0800, "Taper Litwater"
    <Litwater@NOSPAM.com> wrote:
    >after selecting from two table like so-
    >
    >select table1.column, table2.column from table1, table2 ...
    >
    >What is the correct syntax to access the individual table data?
    >
    >With one table I would normally just use- rs("column")
    >
    >TIA
    >
    If both tables contain rows with the same name, you need to alias at
    least one of them. The recordset object does not know where the
    columns come from, so referencing them as table.column at that point
    is not possible.

    select table1.column as t1c, table2.column as t2c from table1,
    table2...

    Then in your recordset object, use...

    rs("t1c") and rs("t2c")

    Dan Brussee Guest

  5. #4

    Default Re: Select from two tables



    Thank you :-)

    "Mike" <Mike@nospam.com> wrote in message
    news:%23yU8P4LnDHA.2304@TK2MSFTNGP11.phx.gbl...
    > same thing. If you have mitiple columns with the same name select by
    using
    > rs(x) where x is the index of the column in the select.
    >
    > Mike
    >
    > "Taper Litwater" <Litwater@NOSPAM.com> wrote in message
    > news:ulF9szLnDHA.2592@TK2MSFTNGP10.phx.gbl...
    > > after selecting from two table like so-
    > >
    > > select table1.column, table2.column from table1, table2 ...
    > >
    > > What is the correct syntax to access the individual table data?
    > >
    > > With one table I would normally just use- rs("column")
    > >
    > > TIA
    > >
    > >
    >
    >

    Taper Litwater Guest

  6. #5

    Default Re: Select from two tables

    <snip>
    If you are returning the same column name from multiple joined tables, then
    you have one of two problems.

    (A) Either both columns mean the same thing, and contain the same data --
    therefore your query is redundant and inefficient and there's no reason to
    access both columns in ASP (or return them with the resultset in the first
    place).

    (B) Or, you chose extremely poor names for your columns. If they don't mean
    the
    same thing, and contain distinct data, then why do they have the same name?
    </snip>

    My suggestion is to fix that problem... either by eliminating redundant
    columns from the SELECT statement in case (A), or by aliasing the columns in
    the SELECT (or properly altering the table(s)) in case (B).


    "Taper Litwater" <Litwater@NOSPAM.com> wrote in message
    news:ulF9szLnDHA.2592@TK2MSFTNGP10.phx.gbl...
    > after selecting from two table like so-
    >
    > select table1.column, table2.column from table1, table2 ...
    >
    > What is the correct syntax to access the individual table data?
    >
    > With one table I would normally just use- rs("column")
    >
    > TIA
    >
    >

    Aaron Bertrand - MVP Guest

Posting Permissions

  • You may not post new threads
  • You may 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