sql - Sorted result differs with inner and left joins in mysql -


I found this irregularity in a query, why is the result different when using internal and left joining? For one, the result is ordered in both the temporary hits table and in the final question?

I gave a little example to show the problem:

  ID # if the cleanup drop temp table exists; Temporary table drop if art is present; # Create temporary table artwork to create temporary tables (id int, title varchar (100), posted date time); Create a temporary table id (id int, artid int); # Enter Dummy Articles in the Arts (ID, Title, Posted) value (1, 'A', '2010-04-01'); Entry into Art (ID, Title, Post) Price (2, 'B', '2010-07-01'); Entry into Art (ID, Title, Post) Price (3, 'C', '2010-06-01'); Entry into Art (ID, Title, Post) Price (4, 'D', '2010-08-01'); # Enter the listing entry for the hit ID (id, artid) value (1, 4); Enter in id (id, artid) value (2, 2); Enter in id (id, artid) value (3, 3); Enter in id (id, artid) value (4, 1); # Execution questions to choose from i.artid, Posted by AID at iartid a.id = i.artid; Select iartid, posted a post i i internal entries at a.id = i.artid; # Cleanup drop temp table if art is present; Floating table drop if id exists;  

The first query returns:

  4,2,3,1 (as expected, post-column is ordered by descending)  

The second one returns:

  1,2,3,4 (sorted by PK?)  

< Div class = "post-text" itemprop = "text">

This is what you want; I.ids selected in the first query 1, 2, 3 (and 4 later, estimated) and they receive D, C and B. in that sequence. In the second table, selected i.ids 2, 3, 4 mailing b, c and a.

Where the condition involves three arbitrarily selected rows, and applied in its sequence; It probably leads to confusion.


Comments