Re: insert ... select .. order by problem
Sinisa Milivojevic <[email protected]>
| Newsgroups | gmane.comp.db.mysql.bugs |
|---|---|
| Message-ID | <[email protected]> |
Alejandro Paz writes: > Hi, > > I use ORDER BY, because I want that order in PTemp > table, so I do not have to order them later (because > they are retrieved several times later). > > 1. Inserting with mysql c.l.i. : > > I get the records well sorted : first by a, secondly > by b and finally by c (ascendig order). I'm using d to > relink both tables in a join. > > select a,b,c from Stock,PTable where Stock.d=PTable.d; > > 2. Inserting with the application : > > I get the records badly sorted : first by a, secondly > by b and finally by c, but in descending order. As all > records has the same value in a, so the records that > in case 1 start with '0' are at the beginning, the > same records here are at the end. I'm using d to > relink both tables in a join. > > select a,b,c from Stock,PTable where Stock.d=PTable.d; > > I thought that was clear when I said reverse order, > sorry. > Hi! The order of retrieval of rows does not necessary has to be the same as the row order in the table. You should get the same result with mysql cli and in application. Try using ..store_result instead of ..use_result function. Still, no order is guaranteed if your SELECT does not use GROUP BY or ORDER BY. Last but not least, if a,b,c are present in both tables, you should specify a table in the select list. -- Sincerely, -- For technical support contracts, go to https://order.mysql.com/?ref=msmi __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <[email protected]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB /_/ /_/\_, /___/\___\_\___/ Fulltime Developer and Support Coordinator <___/ www.mysql.com Larnaca, Cyprus -- MySQL Bugs Mailing List For list archives: http://lists.mysql.com/bugs To unsubscribe: http://lists.mysql.com/[email protected]