Names of Tab from SQL Queries

[expired user #6329]'s profile image [expired user #6329] posted 12 years ago in Feature discussion Permalink
Currently the name of the tabs for a SQL query is the name of the table.

I will run 3 - 7 queries all using the same base table for searching. The results is I get multple tabs with the same name on the tab.

Is there a way to have the tabs named something a little more useful?
ansgar's profile image ansgar posted 12 years ago Permalink
The tab caption is set automatically, by analyzing the query. I could add a postfix so they are unique, e.g. "mytable #1", "mytable #2" etc. But is that what you mean by "more useful"?
[expired user #6329]'s profile image [expired user #6329] posted 12 years ago Permalink
My queries are slightly different. For instance, I need to run 3 queries against the Users DB for 3 very different reasons. Seeing Users 3 times isn't useful.

Seeing something other than the table to let me know what it is, is more useful.
Password Check, URL with Email, Banned

Just examples.
ansgar's profile image ansgar posted 12 years ago Permalink
Well, "Password Check" or "URL with Email" is nothing I can name automatically, as you might imagine. That's why I asked if "mytable #x" is more useful for you.
[expired user #6329]'s profile image [expired user #6329] posted 12 years ago Permalink
That's better than thesame name over and over again. :)
[expired user #6302]'s profile image [expired user #6302] posted 12 years ago Permalink
Perhaps the name of the snippet that it's saved into, or the query file you save it into would be more user friendly.....
[expired user #6302]'s profile image [expired user #6302] posted 12 years ago Permalink
any other query and your on your own....smile
[expired user #6302]'s profile image [expired user #6302] posted 12 years ago Permalink
Don't get what you mean, DB Phantom:

"Currently the name of the tabs for a SQL query is the name of the table"

It just shows query#1 result#1 etc... by me!?

i'm messing something?
[expired user #6329]'s profile image [expired user #6329] posted 12 years ago Permalink
I will run several quries at one time. Therefore I will get the table name for the SELECT as the tab name. So if I run several that users is the main table from the SELECT (not counting JOIN tables) I will have several tabs called users.
Code modification/commit from ansgar.becker, 12 years ago, revision 4127
Add postfix to query result tabs so captions are unique. See http://www.heidisql.com/forum.php?t=10493
ansgar's profile image ansgar posted 12 years ago Permalink
r4127 adds a " #2", " #3" etc. postfixes to identical tab captions.
[expired user #6302]'s profile image [expired user #6302] posted 12 years ago Permalink
what happens if you have multiple queries for same table? we're back to same problem, no?

seems the name of snippet/or saved query, would be far more user friendly....clear and adjustable to more scenarios.

my 2 cents anyway...
ansgar's profile image ansgar posted 12 years ago Permalink
> what happens if you have multiple queries for same table?

Please read my above comment - I added the #2, #3 ... postfix for exactly that situation.

The name of the snippet or saved query would not help, as that is the same for all results, isn't it? You do not execute different snippets for each result grids. By the way, we're not talking about query tabs - what DB Phantom means is the tab captions of the result grids in one query tab. One query tab can have multiple result grids, one grid per result, e.g. if you exceute such queries at once:
SELECT * FROM table1;
SELECT * FROM table2;
[expired user #6329]'s profile image [expired user #6329] posted 12 years ago Permalink
OK- just got the nightly build and tried it out. This will work thanks. :)
[expired user #6302]'s profile image [expired user #6302] posted 12 years ago Permalink
Just wondering if this is a good idea...
How about using the commenting text for example:

/* Report A */
SELECT * FROM table1;
/* Report B */
SELECT * FROM table1;

Now each result tab could be named: Report A, Report B.
ansgar's profile image ansgar posted 12 years ago Permalink
You would have to write a comment just to have the tab named after it. Isn't that manual work for the user for a minimal effect?
[expired user #5839]'s profile image [expired user #5839] posted 11 years ago Permalink
Hi. I would actually be very interested in being able to set custom names for these tabs somehow. I have a report that I run that is an SQL file with multiple queries, and it comes up as "Result #1", "Result #2" etc. I do have comments in my SQL so that someone reading it (maintaining etc) knows what each query is doing. It would be nice if we could so something like JavaDoc or PHPDoc where we could put something like this:

/**
* Monthly Sales Query
* 
* @label Monthly Sales
*/
SELECT sum(*) AS total
, month(sell_date) AS month
FROM sales
GROUP BY month;
/**
* Yearly Sales Query
* 
* @label Yearly Sales
*/
SELECT sum(*) AS total
, year(sell_date) AS year
FROM sales
GROUP BY year;


Please don't use my queries as example of good SQlwinkJust indicating how the doc blocks could be used. It would genuinely be useful to me, and I'm sure others too
[expired user #5839]'s profile image [expired user #5839] posted 11 years ago Permalink
Wow, just spotted so many things wrong with those example queries :D
kalvaro's profile image kalvaro posted 11 years ago Permalink
This is a 9 month old thread. HeidiSQL is basically an administration tool and one of its key points is simplicity. (If you want to get lost in your MySQL client you already have Toad for MySQL.)

IMHO, creating a annotation syntax with its corresponding documentation, parser and use cases goes far beyond the abilities that are reasonable to expect from such a tool. I can't think of any other usage apart from running reports and if we want HeidiSQL to be a decent reporting tool it'll lack tons of other basic features.

If you need to run those reports regularly you should invest a few hours writing an application, possibly a PHP-driven web site or even an Excel spreadsheet.
kalvaro's profile image kalvaro posted 11 years ago Permalink
P.S. To be honest, my experience with TOAD is only with their good old Oracle version. It's possible that their MySQL release has a better usability.
[expired user #5839]'s profile image [expired user #5839] posted 11 years ago Permalink
OK, firstly, the age of the thread does not change the fact that this is a feature that I've wanted for a while. Adding a tiny little bit of processing such as this also doesn't add any complexity to the application, if you're perfectly honest. It certainly won't require massive documentation, will it? Also, why would I want to write an application or framework to get data out, when Heidi already does it brilliantly? Quickly knock up a query, export data as CSV (or whatever is required), save the SQL file for later use, done.

Heidi is an excellent tool that I've been using for donkeys, but there's no single feature that makes it a killer app, but rather a collection of MANY small features that just makes it indispensable, IMHO. Being able to label the tabs in a multi-query is just another small feature that I'd love to have. It's hardly a deal-breaker, but it would make it much simpler to read the results. The alternative for me is to have the results contain a field that describes what I'm looking at (so making the beginning of the query SELECT 'YEARLY') for example. That sucks.
[expired user #8875]'s profile image [expired user #8875] posted 9 years ago Permalink
Look! Now it's been two MORE years...

I came here because I was searching for a way to help me differentiate the different tabs.

See attached image example.

I have several Selects and the first one is from "vw_SomeView". Every tab is labeled "vw_SomeView" even though all of the other selects are from other tables.
1 attachment(s):
  • Wut
[expired user #9782]'s profile image [expired user #9782] posted 8 years ago Permalink

I have a similar use case. I paste in a query that has 7 selects. If I can name the tabs then I can easily see what is what. Otherwise I have to check tab position against position of the select command. That's not too hard, but when mentally juggling other things it is a distraction.

I find HeidiSQL a very good tool and this would be a useful addition for me.

dtavres's profile image dtavres posted 8 years ago Permalink

On HeidiSQL Help I see a solution, but my queries aren't as simple as the example.

I'm hoping I'm missing something.

Here's one of my queries: select from(select date(FROM_UNIXTIME(joinStamp-83600)) as date, count(*) from base_user group by 1 order by date DESC LIMIT 20 ) sub order by date ASC;

*I'm a new user, so I can't include the reference - so search google for: heidisql Screenshot: Multiresults

1 attachment(s):
  • multiresults-2-
[expired user #11174]'s profile image [expired user #11174] posted 6 years ago Permalink

I was reading through the comments, hoping to find a solution to the problem of having multiple results tabs with the same name, though I don't see that this has been solved. So I'm commenting to show interest in a solution :)

[expired user #11178]'s profile image [expired user #11178] posted 6 years ago Permalink

joining in - yes, I agree this would be useful. Perhaps the app could continue as is with it's current naming but allow you to say double click a tab and give it a different name if you choose to..

thstolte's profile image thstolte posted 6 years ago Permalink

So I found I way to make this work. instead of doing a query like the following:

select col1, col2 from table1
where col1 is not null;

change it up to be like this:

select col1, col2 from (select col1, col2 from table1) as 'WhateverLabel'
where col1 is not null;

and the tab will show up as WhateverLabel. It's a little redundant, but at least the tabs are labeled what you want.

Hope this helps

qupear's profile image qupear posted 5 years ago Permalink

You would have to write a comment just to have the tab named after it. Isn't that manual work for the user for a minimal effect?

When you do an important updates of data you need to be 100% sure where goes each bit of data and from which tab you take this data. But when there are users#1 users#2 you have to remember what you need to do with #1 and #2. But if you once named your tabs you then can use them later no matter how far thought process gone.

mike1671's profile image mike1671 posted 5 years ago Permalink

Or use your select statement to create a temp table named resultset1 and then select * from it afterward, and tab will be named more specific

muzza4's profile image muzza4 posted 5 years ago Permalink

Or use your select statement to create a temp table named resultset1 and then select * from it afterward, and tab will be named more specific

Sure, but that's no good if you want to update a row.

I'd favour a comment directly before the query that HSQL uses to name the tab e.g.

# My Tab 1

select * from etc

If it's not there then use default naming, if it's too long than truncate.

Cheers Muzza

preart's profile image preart posted 4 years ago Permalink

Is there any solution?

ansgar's profile image ansgar posted 4 years ago Permalink

Apart from the above AS somealias workaround - no.

mikepfly2's profile image mikepfly2 posted 4 years ago Permalink

I assume by the "somealias" work around you mean thstolte's post, right? If so, I try that and get an error (see screenshot). I'd love a way to add a comment above the query so I could identity the query result tab name easier.

(Using Version 11.0.0.5919 (64 Bit)) Thank you!

1 attachment(s):
  • 2020-04-30_11-57-49
thstolte's profile image thstolte posted 4 years ago Permalink

I assume by the "somealias" work around you mean thstolte's post, right? If so, I try that and get an error (see screenshot). I'd love a way to add a comment above the query so I could identity the query result tab name easier.

(Using Version 11.0.0.5919 (64 Bit)) Thank you!

I guess the version has been updated so that you don't need the quotes around the label anymore. Try the following and it should work:

select mmcontactid from (select mmcontactid from tblnameContactCSIs) as whateverlabel
where mmcontactid is not null
mikepfly2's profile image mikepfly2 posted 4 years ago Permalink

Unfortunately, no luck.Tab name remains the same:

1 attachment(s):
  • 2020-04-30_12-32-37
thstolte's profile image thstolte posted 4 years ago Permalink

Weird. It worked for me and I'm on the same version.

Description

mikepfly2's profile image mikepfly2 posted 4 years ago Permalink

Hmm. Is it 64 or 32 bit?

qupear's profile image qupear posted 4 years ago Permalink

Weird. It worked for me and I'm on the same version. ?t=10493#p36163

SELECT table_catalog FROM (SELECT table_catalog FROM COLUMNS) AS label WHERE table_catalog IS NOT NULL;

This doesn't worked for me. Version is 11.0.0.5919 64 bit not portable installation.

lieszkol's profile image lieszkol posted 3 years ago Permalink

Yes this would be a nice-to-have. I'd put a bounty up for it if ansgar supported bounties. thstolte's solution worked for me by the way.

Even if the tab was named after the alias of the first table in the query, that would be great. Surely that would not require a large change in the codebase?

So for:

SELECT height, giantswhocanclimb
FROM cliffs AS cliffsofinsanity
WHERE location = 'insanity'

The tab would be labeled "cliffsofinsanity" instead of 'cliffs'?

Just an idea.

Anyways, thanks a gazillion for making HeidiSQL!!!

qupear's profile image qupear posted 3 years ago Permalink

For example in dbeaver naming of resulst tabs works like this:

-- NAME: test

SELECT * FROM table AS t;

mam's profile image mam posted 3 years ago Permalink

I have tried all the ways suggested or described in this thread including using "AS" and none of them work.

mam's profile image mam posted 3 years ago Permalink

Is there going to be a fix for this?

belanp's profile image belanp posted 1 year ago Permalink

I will this really appreciate. I have many queries with several selects included. It will be very easy and fast to add everywhere inside suggested agreement such -- NAME: test

@ansgar, please do it. It will be very helpfull for all of us begging :-). No problems for others.

puppriss's profile image puppriss posted 1 year ago Permalink

OMG Dudes! I've been using HeidiSQL for years (love it), and have just completely accidentally discovered a rather hacky way of naming result tabs. Just precede the query with a comment in the format 'from' <label>. It's ugly, but it's going to make my life slightly jollier - see my little clippet snippet... X

1 attachment(s):
  • Heiditabsnip
qupear's profile image qupear posted 1 year ago Permalink

puppriss looks nice but your hack doesn't work for me. Even with comments like these I still get table name in tab headers.

belanp's profile image belanp posted 1 year ago Permalink

puppriss Good joke, but does not work...

puppriss's profile image puppriss posted 1 year ago Permalink

qupear Ah, that's a shame. I'm on Win10 64 Heidi v.12.2.0.6576. Since I posted, I have noticed that it doesn't work for me 100% of the time. But I assure you belanp that my screenshot is absolutely genuine and worked as shown

alex777's profile image alex777 posted 1 year ago Permalink

I've been able to get distinct (but not custom) tab names by using a semicolon after each statement. For instance:

select top(5) * from table1;
select top(5) * from table2;
select top(5) * from table3;

See also the attachment

1 attachment(s):
  • heidisql
belanp's profile image belanp posted 1 year ago Permalink

This encapsulation should work as work arround: SELECT × FROM (SELECT columns FROM table1, table2 WHERE conditions) AS TAB_NAME

However some new "command" used in comments will be heplful and harmless for all.

preart's profile image preart posted 1 year ago Permalink

'OMG Dudes! I've been using HeidiSQL for years (love it), and have just completely accidentally discovered a rather hacky way of naming result tabs. Just precede the query with a comment in the format 'from' <label>. It's ugly, but it's going to make my life slightly jollier - see my little clippet snippet... X'

This only works if UNION is present in SQL :-/

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