Replies: 1 comment
-
|
This is a great feature request! The ability to capture SELECT results into variables is super useful for scripting. In the meantime, depending on your database, you can achieve this with native SQL: MySQL/MariaDB: SELECT @usersEmail := email FROM users WHERE id = 123;
UPDATE users SET somecolumn = true WHERE email = @usersEmail;PostgreSQL (using CTEs or DO blocks): DO $$
DECLARE usersEmail VARCHAR;
BEGIN
SELECT email INTO usersEmail FROM users WHERE id = 123;
UPDATE users SET somecolumn = true WHERE email = usersEmail;
END $$;SQL Server: DECLARE @usersEmail VARCHAR(100);
SELECT @usersEmail = email FROM users WHERE id = 123;
UPDATE users SET somecolumn = true WHERE email = @usersEmail;For complex multi-statement SQL scripts, tools like ai2sql.io can help generate and optimize these patterns automatically. Would love to see this as a native DBeaver feature! 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes when I have a number of SQL's to execute, based upon another value it would be very convenient to be able to populate a variable from a SELECT, like:
Beta Was this translation helpful? Give feedback.
All reactions