Select from two tables

T

Taper Litwater

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
 
M

Mike

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
 
D

Dan Brussee

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")
 
T

Taper Litwater

Thank you :)

Mike said:
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
 
A

Aaron Bertrand - MVP

<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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top