How to execute multiple statements in presto?

by aniya.jaskolski , in category: Third Party Scripts , 4 months ago

How to execute multiple statements in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by haylee.mertz , 4 months ago

@aniya.jaskolski 

In Presto, you can execute multiple statements by separating them with a semicolon (;) as shown below:

1
2
3
4
5
-- Query 1
SELECT column1 FROM table1;

-- Query 2
SELECT column2 FROM table2;


You can also use the DO command to execute multiple statements as a single transaction, like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
DO
$$
DECLARE
    variable1 INT := 1;
    variable2 INT := 2;
BEGIN
    SELECT variable1;
    SELECT variable2;
END
$$


Remember to end each statement with a semicolon (;) when using the DO command.

Related Threads:

How to optimize multiple if statements in powershell?
How to execute multiple commands in php exec?
How to execute a multiple raw query using laravel?
How to execute multiple commands in php exec?
How to get mocha to execute unit tests in multiple subfolders in node.js?
How to attach dynamic value to multiple rows in presto?