Create SELECT template from UPDATE query and vice versa

Timon's profile image Timon posted 2 weeks ago in General Permalink

Hi,

this question actually came up during a discussion with my boss, and I was wondering whether something like this would be possible in HeidiSQL.

For UPDATE statements, it could be very useful to generate a matching SELECT statement as a preview, so the user can quickly check which rows would be affected before executing the UPDATE.

For example, from:

UPDATE mytable SET status = 'done' WHERE category = 'A';

HeidiSQL could generate:

SELECT * FROM mytable WHERE category = 'A';

This could either be inserted into the query tab or copied to the clipboard.

The reverse direction might also be helpful: If a user already has a SELECT statement that filters the intended rows, HeidiSQL could generate a simple UPDATE template from it, for example:

UPDATE mytable SET column_name = <new_value> WHERE category = 'A';

I understand that this would probably only work reliably for simpler SQL statements, but even for common day-to-day queries this could be a very practical helper.

Also, is there already an existing workflow or best practice in HeidiSQL to achieve something similar?

Would such a feature be possible in principle?

Please login to leave a reply, or register at first.