470,638 Members | 1,579 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,638 developers. It's quick & easy.

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
Jul 19 '05 #1
4 4922
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" <Li******@NOSPAM.com> wrote in message
news:ul**************@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

Jul 19 '05 #2


Thank you :-)

"Mike" <Mi**@nospam.com> wrote in message
news:%2****************@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" <Li******@NOSPAM.com> wrote in message
news:ul**************@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


Jul 19 '05 #3
On Mon, 27 Oct 2003 11:03:08 -0800, "Taper Litwater"
<Li******@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")

Jul 19 '05 #4
<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" <Li******@NOSPAM.com> wrote in message
news:ul**************@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

Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by mfyahya | last post: by
1 post views Thread by Ahmet Karaca | last post: by
1 post views Thread by Diffident | last post: by
4 posts views Thread by VK | last post: by
33 posts views Thread by Peter | last post: by
10 posts views Thread by Richard Maher | last post: by
3 posts views Thread by Jeff | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.