SQL and sort order

Ivan Smahin ivan_smahin at valentina-db.com
Thu Mar 2 15:43:14 CST 2006


Hello Steve,

Thursday, March 2, 2006, 3:30:14 PM, you wrote:

> Is there any correlation between the order of requested fields in the SQL and the ORDER BY claus?

> I have this SQL:

> select ax.*, artists.*,  players.* from ax, artists,  players 
> where  players.nSessid = 1 and 
> Players.nAxId = Ax.nId and 
> players.nartid = artists.nid  
> order by ax.nAxSort, Artists.nameidx, artists.nid

> The ax.nSortOrd sorts correctly using this.

> If I change the SQL to this:

> select artists.*,  ax.*, players.* from ax, artists,  players 
> where  players.nSessid = 1 and 
> Players.nAxId = Ax.nId and 
> players.nartid = artists.nid  
> order by ax.nAxSort, Artists.nameidx, artists.nid

> where artists fields come before ax, then the cursor does not sort correctly on ax.nSortOrd.

> This is using Valentina 2.2 and RB2006 on the Mac.

"ORDER BY" clause is not correlated to the column order in "SELECT list".
But  you  have  mentioned  ax.nSortOrd which is not the part of "ORDER
BY".

> I will put a sample on Mantis, but I first wanted to make sure I
> didn't have some dumb SQL misunderstanding.

Put it please - so I will check it.


-- 
Best regards,
 Ivan                            mailto:ivan_smahin ÎÁ valentina-db.com



More information about the Valentina mailing list