sorting the fields in a INSERT INTO statement in the same order as the SELECT statement of the query (or vice versa), taking into account t
Sorting the fields in a INSERT INTO statement in the same order as the SELECT statement of the query, taking into account the column aliases. Thus
INSERT INTO table
(columnA, columnB, columnC)
SELECT foo AS columnB, columnC, bar AS columnA
FROM table2
becomes
INSERT INTO table
(columnB, columnC, columnA)
SELECT foo AS columnB, columnC, bar AS columnA
FROM table2
With a few columns it's no big deal to do it manually but with 20 columns it is.
Displaying a hint if columns are missing is also welcome.
1
vote
Richard
shared this idea