Last active
August 29, 2015 14:22
-
-
Save tophyr/7f05e3ebff910587b26e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE app(aid integer primary key asc); | |
CREATE TABLE event (eid integer primary key asc, aid integer not null); | |
INSERT INTO app (aid) values (1); | |
INSERT INTO app (aid) values (2); | |
INSERT INTO app (aid) values (3); | |
INSERT INTO event (eid, aid) values (1, 1); | |
INSERT INTO event (eid, aid) values (2, 1); | |
INSERT INTO event (eid, aid) values (3, 1); | |
INSERT INTO event (eid, aid) values (4, 2); | |
INSERT INTO event (eid, aid) values (5, 2); | |
INSERT INTO event (eid, aid) values (6, 2); | |
INSERT INTO event (eid, aid) values (7, 3); | |
INSERT INTO event (eid, aid) values (8, 3); | |
INSERT INTO event (eid, aid) values (9, 3); | |
### ACTUAL RESULTS ### | |
sqlite> select app.aid, event.eid from app inner join event on app.aid = event.aid; | |
1|1 | |
1|2 | |
1|3 | |
2|4 | |
2|5 | |
2|6 | |
3|7 | |
3|8 | |
3|9 | |
### DESIRED RESULTS ### | |
sqlite> select app.aid, event.eid from app inner join event on app.aid = event.aid ORDER BY MAGIC; | |
1|1 | |
2|4 | |
3|7 | |
1|2 | |
2|5 | |
3|8 | |
1|3 | |
2|6 | |
3|9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment