Syafiq Azwan
Syafiq Azwan

Reputation: 178

generate sql using HeidiSQL

I would like to ask is there any config that allow HeidiSQL to generate INSERT query that look like:

INSERT INTO state SET ST_ID = NULL, ST_NAME = "lol"

instead of:

INSERT INTO state (ST_ID, ST_NAME) VALUES (NULL, 'lol')

Upvotes: 4

Views: 19476

Answers (2)

francis Guchie
francis Guchie

Reputation: 51

Ah ok, even that is a feature in Heidi:

  1. Double click a table
  2. Go to the query tab
  3. Expand the "Columns in [table]" tree node
  4. a. Right click one column and click "Generate INSERT/UPDATE/DELETE"

    b. or select more columns and then right click. The generated query will use selected columns

as picked from http://www.heidisql.com/forum.php?t=9412

Upvotes: 5

Syafiq Azwan
Syafiq Azwan

Reputation: 178

Solution:

1. Select a table in heidi
2. In the query tab, select desired column from the right panel.
3. Right click on the selected column and select 'Generate Update..'
4. In the generated query, change the 'UPDATE' command to 'INSERT INTO'.
5. Delete the 'WHERE' command

Upvotes: 9

Related Questions