A tool for transforming MySQL insert statements to update statements and vice versa.
In MySQL Workbench, as with probably many other tools, you are able to output insert and update statements. This is helpful, but you will have to edit in all the substitutions for prepared statements again. With this tool you only need to write either insert or an update statement and the tool will transform it to the other form.
The tool is also supposed to produce exactly what MySQL Workbench would produce... well some spaces are missing after transformation, otherwise it is 95% similar to the MySQL Workbench output.
The tool is not too strict about syntax, but might break in some cases. The more correct the syntax the better the app will work.
NOTE: You should probably be using 'UPSERT' pattern to begin with than to write separate insert and update statements, but in case you have to write them separately for some reason, this tool will help.
The tool can be found online, here: click
- Implemented a shareable link generation
- Implemented SQL to ajax transform
- Implemented ajax to SQL transform
- Fixed some edge cases with queries and ajax that broke the app
- Implemented function generator
- Bugfixes
INSERT INTO `somedb`.`sometable`
(`somecolumnA`,
`somecolumnB`,
`somecolumnC`,
`somecolumnD`,
`somecolumnE`,
`somecolumnF`,
`somecolumnG`,
`somecolumnH`)
VALUES
(:somesubstitutionA,
:somesubstitutionB,
:somesubstitutionC,
:somesubstitutionD,
:somesubstitutionE,
:somesubstitutionF,
:somesubstitutionG,
:somesubstitutionH);
UPDATE `somedb`.`sometable`
SET
`somecolumnA` = :somesubstitutionA,
`somecolumnB` = :somesubstitutionB,
`somecolumnC` = :somesubstitutionC,
`somecolumnD` = :somesubstitutionD,
`somecolumnE` = :somesubstitutionE,
`somecolumnF` = :somesubstitutionF,
`somecolumnG` = :somesubstitutionG,
`somecolumnH` = :somesubstitutionH
WHERE `someid` = :somevalue;
$.ajax(
{
type: "type",
url: "url",
data:
{
somecolumnA: :somesubstitutionA,
somecolumnB: :somesubstitutionB,
somecolumnC: :somesubstitutionC,
somecolumnD: :somesubstitutionD,
somecolumnE: :somesubstitutionE,
somecolumnF: :somesubstitutionF,
somecolumnG: :somesubstitutionG,
somecolumnH: :somesubstitutionH
}
});