[thelist] Same Column Name Different Tables

rudy r937 at interlog.com
Wed Mar 12 14:10:46 CST 2003


>  (In some instances the Link/Title combo goes to 24)

would you like the sermon about why this is a terrible idea?   ;o)

>   SELECT p.productID, p.ProductDescription
>        , Table_A.*
>        , Table_B.*
>     FROM A_URLS Table_A
>        , B_URLS Table_B
>    WHERE bunch_of_stuff = other_stuff
> ORDER BY that

the p table is missing

> Can I do this:
>   <a href="<%=Recordset1.fields.item("Table_A.Link1").value%>"
target="_top"
>     title="<%=Recordset1.fields.item("Table_A.Title1").value%>">
>     <%=Recordset1.fields.item("Table_A.Title1").value%></a>

no

> If I can't, how can I reference or differentiate same column names from
> different tables in my ASP code?

you will have to assign each of the "duplicate" columns an alias

this means you cannot use "select star"

so you will have to write

   SELECT p.productID
        , p.ProductDescription
        , Table_A.Link1         as TableAlink1
        , Table_A.Title1        as TableAtitle1
        , Table_A.Link2         as TableAlink2
        , Table_A.Title2        as TableAtitle2
        , Table_A.Link3         as TableAlink3
        , Table_A.Title3        as TableAtitle3
   et cetera


rudy



More information about the thelist mailing list