Which version of SQLite3 are you using? Tip of trunk seems to work correctly ...
SQLite version 3.30.0 2019-08-24 20:18:04 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> create table x(x); sqlite> create table y(y); sqlite> insert into x values (3),(2),(4),(1); sqlite> insert into y select x from x order by x asc; sqlite> select * from x; 3 2 4 1 sqlite> select * from y; 1 2 3 4 Can you post the output of EXPLAIN INSERT INTO CompanyDetails2 SELECT * FROM CompanyDetails WHERE CompanyDetails.ID > 0 ORDER BY CompanyDetails.RIC ASC -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of André Borchert >Sent: Sunday, 25 August, 2019 15:10 >To: sqlite-users@mailinglists.sqlite.org >Subject: [sqlite] ORDER BY is ignored during INSERT INTO > >Hello, > >I try to copy one table into a second identical one. Once the second >table >is created I want to move the content over sorted by ASC. > >The issue is that the ORDER BY statement gets ignored during a INSERT >INTO: > >INSERT INTO CompanyDetails2 SELECT * FROM CompanyDetails WHERE >CompanyDetails.ID > 0 ORDER BY CompanyDetails.RIC ASC > >When the SELECT query is executed alone, the content is sorted fine >as >expected. > >Andre >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users