MySQL

How to Run Multiple SQL Statements in a Single Execution

Run multiple SQL statements in one execution on Nobregas Panel. Separate statements with semicolons for batch processing.

3 min read 14 views Updated Mar 17, 2026

The Nobregas MySQL Panel supports executing multiple SQL statements in one go. Separate each statement with a semicolon and the panel will run them sequentially, returning results for each one.

How Multi-Statement Execution Works

When you enter multiple SQL statements separated by semicolons, the panel:

  1. Splits your input into individual statements.
  2. Executes each statement in order against the selected database.
  3. Returns the result of the last statement (or a combined result summary).

Writing Multiple Statements

Separate each statement with a semicolon (;). You can put them on one line or across multiple lines:

Single Line

INSERT INTO logs (msg) VALUES ('start'); SELECT * FROM logs;

Multi-Line (Recommended)

INSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com');
INSERT INTO users (name, email) VALUES ('Bob', 'bob@example.com');
SELECT * FROM users ORDER BY id DESC LIMIT 5;

Common Multi-Statement Use Cases

Inserting Multiple Rows

INSERT INTO products (name, price) VALUES ('Widget A', 9.99);
INSERT INTO products (name, price) VALUES ('Widget B', 14.99);
INSERT INTO products (name, price) VALUES ('Widget C', 24.99);

Setup and Verify

CREATE TABLE IF NOT EXISTS temp_data (id INT AUTO_INCREMENT PRIMARY KEY, value TEXT);
INSERT INTO temp_data (value) VALUES ('test');
SELECT * FROM temp_data;

Cleanup Operations

DELETE FROM sessions WHERE expires_at < NOW();
DELETE FROM tokens WHERE created_at < DATE_SUB(NOW(), INTERVAL 30 DAY);
SELECT 'Cleanup complete' AS status;

Important Considerations

Execution Order

Statements run sequentially from top to bottom. If Statement 2 depends on Statement 1 (e.g., inserting then selecting), they will execute in the correct order.

Error Handling

If any statement fails, the execution stops at that point. Statements before the error have already been applied. Statements after the error are not executed. Check the error message to identify which statement failed.

No Transactions

Each statement is auto-committed. There is no implicit transaction wrapping multiple statements. If the third out of five statements fails, the first two have already been committed and cannot be rolled back.

Result Display

The query results panel typically shows the output of the last SELECT statement or a summary of affected rows from all statements.

Tips for Multi-Statement Queries

  • Always end with a SELECT if you want to see results after modifications.
  • Test individual statements before combining them, especially destructive ones.
  • Use comments to organize complex multi-statement scripts:
-- Create table
CREATE TABLE IF NOT EXISTS settings (key_name VARCHAR(100), value TEXT);

-- Insert defaults
INSERT INTO settings VALUES ('site_name', 'My App');
INSERT INTO settings VALUES ('version', '1.0');

-- Verify
SELECT * FROM settings;

Was this article helpful?