distal-attribute
distal-attribute
distal-attribute
distal-attribute

How to Display Table Names in query tab??

djlerman posted 4 years ago in General
when I create and run a query (in the query tab) that selects from or joins several tables, How do I get the table name to display in the results along with the fields names?

Thank you,
~Donavon
ansgar posted 4 years ago

djlerman wrote: How do I get the table name to display in the results



You mean, that HeidiSQL is displaying "Result #1", "Result #2" and so forth? That's for cases in which the table name is not determinable, as you say with joins.
djlerman posted 4 years ago
This is what I would like to do.

select t1.field1, t2.field1
from table1 t1, table2 t2

CURRENT OUTPUT:
field1 field1
blablabla blablabla
blablabla blablabla
blablabla blablabla

OUTPUT IM LOOKING FOR:
t1.field1 t2.field1
blablabla blablabla
blablabla blablabla
blablabla blablabla
djlerman posted 4 years ago
Sorry. I can't edit my posts and I wanted to add this..

In other words I have more then one table with the same field names. When I do a select in the query tab just the field names show up, so I don't know which field name is from which table.
ansgar posted 4 years ago
Ah I see. Makes sense for joins but feels ugly when you do some simple SELECT * FROM tbl doesn't it?

kalvaro posted 4 years ago
Just assign aliases:

select t1.field1 AS 't1.field1', t2.field1 AS 't2.field1'
from table1 t1, table2 t2



HeidiSQL displays names in the same way any other SQL tool. Anything else would be confusing IMHO.

Please login to leave a reply, or register at first.