Board index » delphi » Select from two tables in two alias

Select from two tables in two alias

I have two exact same tables located in two alias.
How do I select from the two tables and join the result together??

  Select * from Table1
  union all
  select * from Table2

Can I add the alias name infront of the Table name??
I can't add path name as I usually did because the two alias is made
from two MSAccess Table.

Thanks

 

Re:Select from two tables in two alias


Add the alias like this:

        blah blah from ":AnAlias:Table1"
        blah blah from ":AnotherAlias:Table2"

(This certainly works for Paradox tables w/ BDE, but I've never used Access.)

Quote
In article <35caba4e.82133...@News.hk.super.net>, Anders LEE (and...@aelhk.com) writes:

>I have two exact same tables located in two alias.
>How do I select from the two tables and join the result together??

>  Select * from Table1
>  union all
>  select * from Table2

>Can I add the alias name infront of the Table name??
>I can't add path name as I usually did because the two alias is made
>from two MSAccess Table.

Stephen Brown
sbr...@sprocket.win-uk.net
+44 (0)171 704 0702

Re:Select from two tables in two alias


Quote
sbr...@sprocket.win-uk.net (Stephen Brown) wrote:
>Add the alias like this:

>        blah blah from ":AnAlias:Table1"
>        blah blah from ":AnotherAlias:Table2"

>(This certainly works for Paradox tables w/ BDE, but I've never used Access.)

   Thanks for your reply.
   I tried but no luck.
   MSACCESS driver doesn;t like that.

   I guess it;s because it is handle by the MS routine instead of
Borland. such as if I do a select * from "group" is no good (good for
other driver!) but has to change to select * from [group] for this
alias.

  Any other hints??

Re:Select from two tables in two alias


Anders,

I probably leaped in a bit too quickly, given that I don't have any
experience with Access...!

However, as I understand it, Delphi still needs to use the Borland Database
Engine to connect (via ODBC) to Access tables.  Have you used the BDE
Configuration to set up aliases to the two tables?  If so, can you run a
simple query on one table using
                Select * from ":YOURALIAS:YourTable"  ?

Regards,
        Stephen

Quote
In article <35cd8874.17790...@news.hk.super.net>, Anders LEE (and...@aelhk.com) writes:
>sbr...@sprocket.win-uk.net (Stephen Brown) wrote:

>>        blah blah from ":AnAlias:Table1"
>>        blah blah from ":AnotherAlias:Table2"

>>(This certainly works for Paradox tables w/ BDE, but I've never used Access.)

>   Thanks for your reply.
>   I tried but no luck.
>   MSACCESS driver doesn;t like that.

>   I guess it;s because it is handle by the MS routine instead of
>Borland. such as if I do a select * from "group" is no good (good for
>other driver!) but has to change to select * from [group] for this
>alias.

Stephen Brown
sbr...@sprocket.win-uk.net
+44 (0)171 704 0702

Other Threads