Hi,

Does anyone know if there is a way in MySQL to have it return the column names qualified with the table name? For example, suppose I have the query,

SELECT * FROM Items, Sales;

and the tables Items and Sales both only contain columns named ID and Count. By default, MySQL just adds a one to the duplicated names(in this example it would return a table with fields ID, Count, ID1, Count).

Instead of this, I want it to return the new table with the columns named as Items.ID, Items.Count, Sales.ID, Sales.Count, without me having to specify individually what to rename each column. Is this possible?

Thanks very much for any help.

Well, can you tell me why you want to create a resultset which has pairwise exactly duplicate columns?

You need to specify them individually.

You know that the resultset of the cartesian product (select * from a,b) is extremely rarely useful.

-- tesu

It's for a front end program I'm making for a business. Having the field names qualified is very preferable to having names with 1 appended on the end.

Well, then you should qualify your duplicate columns, such a kind

select x.a as "a from x", y.a as "a from y"
from t1 x join t2 y on x.ca = y.cb ...


Maybe I got you wrong and you would like to add the table name to the row's values themselves?

Can you give a simple instance/example?


-- tesu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.