0

enter image description hereI have several queries in the editor, each terminating with a semi-colon (I am teaching myself SQL and so in the editor is a mix of queries and notes like below):

SELECT * FROM orders WHERE order_date >= '2019-01-01';

-- AND operator

SELECT * FROM customers WHERE birth_date > '1990-01-01' AND points > 1000;

-- OR operator

SELECT * FROM customers WHERE birth_date > '1990-01-01'OR points > 1000 AND state = 'VA';

-- NOT operator

-- Exercise: FROM order_items table get the items -- for order #6 -- where total price is greater than 30

SELECT * FROM order_items WHERE order_id = 6 AND quantity * unit_price >= 30;


When I first began using MYSQL, I would run a query and only the last SELECT statement would run and the results would show in the result tab. The ACTION OUTPUT would show the time-stamp which clearly indicated only the last SELECT statement in the editor was run.

Now, all queries ending with a semi-colon are running simultaneously and each appears on its own tab and in the ACTION OUTPUT section on the bottom (i.e., "orders43", "customers44", "customers45" and so on.)

The only way I can get the most recent result is by highlighting the specific SELECT statement and running the query. However, I want to know why the results aren't just "overriding" each other and the most recent SELECT statement being the results displayed in the same result tab...

At this rate, I'll have hundreds of result tabs for each query ending with a semi-colon, and this is clearly not what I want nor was it how the workbench was working for me up until recently.

I am not sure why this is occurring, or how to stop it.

Any help would be greatly appreciated.

Thanks!

  • 1
    This is an artifact of Workbench; it is a distraction from learning SQL. – Rick James Nov 14 at 4:24
1

You have actually 3 possibilities to run the queries:

  1. Run everything that's in the editor. This is like running an external script. Workbench opens a result tab for each statement that returns a result set. Use the flash icon or cmd/ctrl+shift+enter to execute (cmd on macOS, otherwise ctrl).
  2. Select a single statement or multiple statements and press the same shortcut as in point 1. This will only run the selected code. The editor is clever enough to find statement boundaries automatically to run complete statements.
  3. Place your cursor in the statement you want to run and press cmd/ctrl+enter. This will only run this single statement (and hence only show a single result set).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.