DBeaver multiple selects in one tab - database

I would like to have multiple select statements in one tab.
I will give a example.
SELECT * from TableA
SELECT * from TableB
SELECT * from TableB
Result I would like to see:
Result from table A
Result from table B
result from table C
Is it possible to have something like that? I dont want to open multiple tabs, I would like to have multiple results in one tab in text mode.

Just click this button:
or Alt + x

I also need an answer for this: I want the results from several different queries, all in only one single tab, in text mode.
If that is not possible, getting all results logged to a single text file on the client filesystem will work too.

Related

How to match a substring exactly in a string in SQL server?

I have a column workId in my table which has values like :
W1/2009/12345, G2/2018/2345
Now a user want to get this particular id G2/2018/2345. I am using like operator in my query as below:
select * from u_table as s where s.workId like '%2345%' .
It is giving me both above mentioned workids. I tried following query:
select * from u_table as s where s.workId like '%2345%' and s.workId not like '_2345'
This query also giving me same result.
If anyone please provide me with the correct query. Thanks!
Why not use the existing delimiters to match with your criteria?
select *
from u_table
where concat('/', workId, '/') like concat('%/', '2345', '/%');
Ideally of course your 3 separate values would be 3 separate columns; delimiting multiple values in a single column goes against first-normal form and prevents the optimizer from performing an efficient index seek, forcing a scan of all rows every time, hurting performance and concurrency.

Is it possible to simplify this LIKE statement and get rid of duplication?

There are few rows in a table:
just text, should not be selected
...parameter1:...
...parameter2:...
...parameter:...
...parameter7:... should not be selected
I use this query to select parameters but it looks like some kind of duplication. Can you tell me, please, is it possible to simplify "where" clause and combine this likes into single one?
SELECT * FROM table1 WHERE text LIKE '%parameter[1-2]:%' OR text LIKE '%parameter:%'

Get columns to autocomplete in Microsoft SQL Server Management Studio

Is there a way to do this?
When I start writing SELECT [ I'd like the columns that are available to pop up so I can choose from them.
Currently, to know the columns I'm doing a SELECT * in another query. It takes a very long time to navigate through Object Explorer and find my table + expand the columns, too.
No IntelliSense options show up for me either to configure this.
If you know the table name, type in:
select * from [your tablename]
After that, highlight the table name, then press Alt + F1 on your keyboard.
You will then be prompted all the column names of the table.
Select all the columns you require, then press Ctrl + C on your keyboard.
Remove the "*" from your select and paste the column names.
You then just need to add the commas in front / the back, depending on your preference.
Hope this helps.

problem with sqlite database query, the distinct query not working

in my sqlite database, a table named image contains three fields label, url and index.
I wrote the following piece of code for fetching data from database: "SELECT DISTINCT(label), index from image;". In my table there is a label 'Cat' 3 times. According to this code the code must show only one 'Cat' from my database. But it won't working. It fetches all three 'Cat' label. Why it happens? please help me to find a possible solution. index field is different for all three 'Cat' labels.
The DISTINCT keyword is not a function, it specifies that duplicate rows should be removed from the results:
If the simple SELECT is a SELECT DISTINCT, then duplicate rows are
removed from the set of result rows before it is returned
What you are trying to accomplish probably requires you to group by label:
SELECT label, index FROM image GROUP BY label
Try this:
select label, index from image
where label in (select distinct label from image)

How to list all columns of a given sql query

is there an easy way to get a list of all columns of a SQL query?
They are listed in the header of the results window of SSMS but I can't copy them.
Thanks in advance.
EDIT:
sorry, I found it myself after a little googling:
http://vidmar.net/weblog/archive/2008/06/05/save-sql-query-results-with-column-names-in-msssms.aspx
Go to Query -> Query Options and check the following box
If you change to Results To Text, then you can copy them.
To save actually executing the full query just to get the column names, you could also do:
SET FMTONLY ON;
SELECT * FROM SomeTable;
This will just return the metadata about the columns the query returns. Saves waiting around if the query is meaty.
Change the result window to 'Results to text' instead of 'Results to grid'.
This can be done by clicking of the on of the Icons above the query window. It looks somewhat like a notepad icon.

Resources