Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Ensure SQL Select Returns Tablename

Author  Topic 

Birdie
Starting Member

1 Post

Posted - 2012-03-04 : 09:49:30
I'm using the following SQL Select statement on a MS Access database:

SELECT TABLE1.*,TABLE2.*,TABLE3.*
FROM (TABLE1 LEFT OUTER JOIN TABLE2 ON TABLE1.ID = TABLE2.USER) LEFT OUTER JOIN TABLE3 ON TABLE1.ID = TABLE3.USER
WHERE TABLE1.ID={IDVALUE};

When it comes to returning the values of columns with the same name, the driver I use at home returns the tablename in the query returned (e.g. TABLE1.ID, TABLE2.ID etc.), whilst the driver online only returns the columnnames (e.g. ID, ID etc.). Is there any way to force the driver to conclude the tablename in the query returned, regardless of the settings on the driver used.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-04 : 10:19:01
best way to do this is to give aliases to columns to avoid confusion, like TABLE1.ID AS T1ID, TABLE2.ID AS T2ID etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -