Is there a way to simulate the OUTPUT clause in MySQL, as we have a OUTPUT clause in SQL Server.
Here is the kind of query I have
UPDATE employee SET empage = 10 OUTPUT INSERTED.empid WHERE (empage < 10)
As I need to have this functionality for MySQL server database too.
Kindly suggest the best way to achieve this functionality.
The OUTPUT clause returns columns from the table being deleted ( deleted. ProductID , deleted. ProductPhotoID ) and columns from the Product table. This table is used in the FROM clause to specify the rows to delete. SQL Copy.
MySQL Shell can print results in table, tabbed, or vertical format, or as pretty or raw JSON output. From MySQL Shell 8.0. 14, the MySQL Shell configuration option resultFormat can be used to specify any of these output formats as a persistent default for all sessions, or just for the current session.
7 Output Panel. The Output is located at the bottom of MySQL Workbench. Its select box includes the Action Output , History Output , and Text Output options.
On the View menu, click Other Windows, and then click Output.
employee
table, select and insert values into another table, and then update and unlock employee
table.EDIT:
I have tried one scenario with InnoDb table, seems it works -
START TRANSACTION; SELECT * FROM table WHERE id = 1 FOR UPDATE; -- lock rows -- Or call this select to insert and lock rows -- INSERT INTO table_output SELECT * FROM table WHERE id = 1 FOR UPDATE; -- Make modifications UPDATE table SET column1 = '111' WHERE id = 1; COMMIT;
SELECT statement (FOR UPDATE clause)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With