473,289 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

MS Excel /myodbc drops column aliases (with joined tables)

With command-line interface ( 3.23.37, UNIX Socket ) all is well with
column aliasing. However, column aliases disappear in Excel, over
ODBC, when there are multiple (joined) tables in the query.

I run the following query with aliased columns with CLI:

select table1.c1 as 'pet category', table1.c2 as 'item', table1.c3 as
'quantity', table2.c2 as 'attendant' from table1 left outer join
table2 on (table1.c1=table2.c1);
+--------------+--------+----------+------------+
| pet category | item | quantity | attendant |
+--------------+--------+----------+------------+
| dog | leash | 3 | Dan Miller |
| cat | collar | 5 | Kim Sloan |
| dog | collar | 4 | Dan Miller |
+--------------+--------+----------+------------+
3 rows in set (0.00 sec)

and all is well. The table1.c1 column is labeled as 'pet category',
table1.c2 as 'item', etc., etc.

But executing this same query in Excel ODBC my labels revert to the
original column names, and the aliases "peth category", "item",
....etc, are ignored:
c1 c2 c3 c2

Interestingly, though, Excel/MyODBC _retains_ column aliases for
single-table queries.

Is there some setting that can correct this? My
Edit->Options->"Qualify table names in SQL statement" box is grayed
out. So is the "Prodedures" button in the File->Execute SQL dialogue.

This phenomenon occurs in many versions of Excel, including 2000 and
97.

Thanks!

andrew
Jul 19 '05 #1
3 6003
After posting my message (quoted here) I discovered a case where Excel
drops the column alias with one table in the query. My query is

select schools.*, if( sid between 5000 and 6000, 1, 0) as 'do'
from schools
order by do, dist, name

Please note the "do" alias and the IF statement column it represents.
In this column a row is qualified (with either 1 or 0), based on the
IF condition, then the value is used in one of the sort levels (the
first one). The "order by" syntax lets you use the alias you've set
in the select clause...

I was happy to discover that aliases can be more than cosmetic - that
they can be as functional as allowing a sort otherwise impossible
(impossible without the alias).

And now I am suffering from this Excel alias omission problem where,
for a query such as above, the aliases get erased, and Excel tells me
"unknown column 'do' in order clause", after having wiped that which
it complains it can't find, from the select clause. Frustrating!

Any ideas?
thanks in advance


se*****@scssi.org (Andrew) wrote in message news:<a8**************************@posting.google. com>...
With command-line interface ( 3.23.37, UNIX Socket ) all is well with
column aliasing. However, column aliases disappear in Excel, over
ODBC, when there are multiple (joined) tables in the query.

I run the following query with aliased columns with CLI:

select table1.c1 as 'pet category', table1.c2 as 'item', table1.c3 as
'quantity', table2.c2 as 'attendant' from table1 left outer join
table2 on (table1.c1=table2.c1);
+--------------+--------+----------+------------+
| pet category | item | quantity | attendant |
+--------------+--------+----------+------------+
| dog | leash | 3 | Dan Miller |
| cat | collar | 5 | Kim Sloan |
| dog | collar | 4 | Dan Miller |
+--------------+--------+----------+------------+
3 rows in set (0.00 sec)

and all is well. The table1.c1 column is labeled as 'pet category',
table1.c2 as 'item', etc., etc.

But executing this same query in Excel ODBC my labels revert to the
original column names, and the aliases "peth category", "item",
...etc, are ignored:
c1 c2 c3 c2

Interestingly, though, Excel/MyODBC _retains_ column aliases for
single-table queries.

Is there some setting that can correct this? My
Edit->Options->"Qualify table names in SQL statement" box is grayed
out. So is the "Prodedures" button in the File->Execute SQL dialogue.

This phenomenon occurs in many versions of Excel, including 2000 and
97.

Thanks!

andrew

Jul 19 '05 #2
After posting my message (quoted here) I discovered a case where Excel
drops the column alias with one table in the query. My query is

select schools.*, if( sid between 5000 and 6000, 1, 0) as 'do'
from schools
order by do, dist, name

Please note the "do" alias and the IF statement column it represents.
In this column a row is qualified (with either 1 or 0), based on the
IF condition, then the value is used in one of the sort levels (the
first one). The "order by" syntax lets you use the alias you've set
in the select clause...

I was happy to discover that aliases can be more than cosmetic - that
they can be as functional as allowing a sort otherwise impossible
(impossible without the alias).

And now I am suffering from this Excel alias omission problem where,
for a query such as above, the aliases get erased, and Excel tells me
"unknown column 'do' in order clause", after having wiped that which
it complains it can't find, from the select clause. Frustrating!

Any ideas?
thanks in advance


se*****@scssi.org (Andrew) wrote in message news:<a8**************************@posting.google. com>...
With command-line interface ( 3.23.37, UNIX Socket ) all is well with
column aliasing. However, column aliases disappear in Excel, over
ODBC, when there are multiple (joined) tables in the query.

I run the following query with aliased columns with CLI:

select table1.c1 as 'pet category', table1.c2 as 'item', table1.c3 as
'quantity', table2.c2 as 'attendant' from table1 left outer join
table2 on (table1.c1=table2.c1);
+--------------+--------+----------+------------+
| pet category | item | quantity | attendant |
+--------------+--------+----------+------------+
| dog | leash | 3 | Dan Miller |
| cat | collar | 5 | Kim Sloan |
| dog | collar | 4 | Dan Miller |
+--------------+--------+----------+------------+
3 rows in set (0.00 sec)

and all is well. The table1.c1 column is labeled as 'pet category',
table1.c2 as 'item', etc., etc.

But executing this same query in Excel ODBC my labels revert to the
original column names, and the aliases "peth category", "item",
...etc, are ignored:
c1 c2 c3 c2

Interestingly, though, Excel/MyODBC _retains_ column aliases for
single-table queries.

Is there some setting that can correct this? My
Edit->Options->"Qualify table names in SQL statement" box is grayed
out. So is the "Prodedures" button in the File->Execute SQL dialogue.

This phenomenon occurs in many versions of Excel, including 2000 and
97.

Thanks!

andrew

Jul 19 '05 #3
After posting my message (quoted here) I discovered a case where Excel
drops the column alias with one table in the query. My query is

select schools.*, if( sid between 5000 and 6000, 1, 0) as 'do'
from schools
order by do, dist, name

Please note the "do" alias and the IF statement column it represents.
In this column a row is qualified (with either 1 or 0), based on the
IF condition, then the value is used in one of the sort levels (the
first one). The "order by" syntax lets you use the alias you've set
in the select clause...

I was happy to discover that aliases can be more than cosmetic - that
they can be as functional as allowing a sort otherwise impossible
(impossible without the alias).

And now I am suffering from this Excel alias omission problem where,
for a query such as above, the aliases get erased, and Excel tells me
"unknown column 'do' in order clause", after having wiped that which
it complains it can't find, from the select clause. Frustrating!

Any ideas?
thanks in advance


se*****@scssi.org (Andrew) wrote in message news:<a8**************************@posting.google. com>...
With command-line interface ( 3.23.37, UNIX Socket ) all is well with
column aliasing. However, column aliases disappear in Excel, over
ODBC, when there are multiple (joined) tables in the query.

I run the following query with aliased columns with CLI:

select table1.c1 as 'pet category', table1.c2 as 'item', table1.c3 as
'quantity', table2.c2 as 'attendant' from table1 left outer join
table2 on (table1.c1=table2.c1);
+--------------+--------+----------+------------+
| pet category | item | quantity | attendant |
+--------------+--------+----------+------------+
| dog | leash | 3 | Dan Miller |
| cat | collar | 5 | Kim Sloan |
| dog | collar | 4 | Dan Miller |
+--------------+--------+----------+------------+
3 rows in set (0.00 sec)

and all is well. The table1.c1 column is labeled as 'pet category',
table1.c2 as 'item', etc., etc.

But executing this same query in Excel ODBC my labels revert to the
original column names, and the aliases "peth category", "item",
...etc, are ignored:
c1 c2 c3 c2

Interestingly, though, Excel/MyODBC _retains_ column aliases for
single-table queries.

Is there some setting that can correct this? My
Edit->Options->"Qualify table names in SQL statement" box is grayed
out. So is the "Prodedures" button in the File->Execute SQL dialogue.

This phenomenon occurs in many versions of Excel, including 2000 and
97.

Thanks!

andrew

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
3
by: bawar | last post by:
Hey, I can say I belong to the newbies in this subject. I own my own website with mySQL-databases, but now I have to show one table of those mySQL-databases in an excel worksheet. It is the...
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
3
by: Geir Baardsen | last post by:
Hi! From one of my manufacturers I get new prices in an excel spreadsheet. Now I want to import this data to my access db. However, there is a difference: The items in MyAccess.db...
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
4
by: Bernie Yaeger | last post by:
I use the following writexml method to convert a dataset/datatable to .xml: ds.WriteXml(mstrpath, XmlWriteMode.WriteSchema) ds.WriteXmlSchema(mstrpathxsd) The path strings are simple full...
1
by: Eric E | last post by:
Hi, I'm trying to write a recordset-returning function that returns a values from a base table, and one column from a joined table, where the joined table varies according to a field of the base...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.