RE: Help with ORDER BY

2011-02-07 Thread Rolando Edwards
orre...@gmail.com] Sent: Monday, February 07, 2011 1:08 PM To: mysql@lists.mysql.com Subject: Help with ORDER BY I currently have a query that organizes search results for volunteers that should be called for projects based on how close they live to a project the and there past attendance. Currently d

Help with ORDER BY

2011-02-07 Thread Richard Reina
I currently have a query that organizes search results for volunteers that should be called for projects based on how close they live to a project the and there past attendance. Currently doing "SELECT name, city, state, phone, prods_done, cancels, miles FROM volunteer_search WHERE project_id =

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Richard
Yes that would be easier, except that I would still have to create a tempory table to add 10 days onto the ones which have a status waiting for answer from customer and have not been answered for more than 10 days. This system is for customers who do not have an account yet to contact me. And

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Ben Clewett
Richard, The query I gave you required the column 'o' to be calculated for each row at the time of gathering the data. When all rows have been gathered, the data will be stored and sorted in a temporary table. This temporary table will be in memory or on disk depending on the setting of the

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Andy Wallace
Not sure, but perhaps an even simpler method would be to consider the initial insert an update as well... so the update column would always have a value. Then the sort would (I believe) always be in the order you want, and if you need to differentiate between rows that are new vs rows that are upd

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Tim McDaniel
On Tue, 8 Apr 2008, Richard <[EMAIL PROTECTED]> wrote: Kristian Myllym?ki a ?crit : mysql version? http://dev.mysql.com/doc/refman/5.0/en/case-statement.html order by case when updated is not null then updated else created end desc; Hello I've tried the following with mysql 4.1.11 SELECT *

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Richard
Thanks, This is for the unanswered list of questions, so the output list (not the list stored in the mysql database) should never go over 100. by scalable, do you mean alot of ressources being used or a long wait for the answer? Because I belive I Could just use a simple limit if I needed to

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Ben Clewett
Richard, No problem, glad it works. But note: this is not scalable. If you have more than a few hundred rows, you may want to think about a better solution, like storing the order field permanetly and giving it an index :) Ben Richard wrote: Thanks, it works like a charm :) Ben Clewett a

Re: Help with ORDER BY using two colomns [ solved thankyou :) ]

2008-04-08 Thread Richard
Thanks, it works like a charm :) Ben Clewett a écrit : A modification to my last email, try: SELECT *, IF(update != '', update + 10, date) AS o FROM my_table ORDER BY o DESC; +-+--++--+ | num | date | update | o| +-+--++--+ | 5 | 40 | 90

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Ben Clewett
A modification to my last email, try: SELECT *, IF(update != '', update + 10, date) AS o FROM my_table ORDER BY o DESC; +-+--++--+ | num | date | update | o| +-+--++--+ | 5 | 40 | 90 | 100 | | 2 | 10 | 60 | 70 | | 6 | 50 |

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Ben Clewett
I think the easiest is to create a new logical column with the correct ordering, something like: SELECT *, IF(update != '', update, date) AS o FROM my_table ORDER BY o DESC; I note that both 'update' and 'date' are reserved works :) Also worth noting that this cannot be assigned an index an

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Richard
Thanks, I think that your solution will be sufficient for my needs, however I would still like to know for my personal knowledge how to manage correctly this kind of need. And to make it more complicated I've just rearlised that there is another element to take into account, I would need to

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Rafael Barbolo Lopes
Can't you do Something like: ORDER BY (update,date) The major column of ordering would be update and the second date. I'm not sure about this "solution" On Tue, Apr 8, 2008 at 8:54 AM, Richard <[EMAIL PROTECTED]> wrote: > Hello I've tried the following with mysql 4.1.11 > > SELECT * FROM quick

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Richard
Hello I've tried the following with mysql 4.1.11 SELECT * FROM quick_contact WHERE (`status` = '0') OR (`status` = '2' AND `update` < '".(time()-864000)."') CASE WHEN `update` = '' THEN ORDER BY `date` DESC ELSE ORDER BY `update` DESC END CASE; It does not work but, is it my code that is wron

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Kristian Myllymäki
mysql version? http://dev.mysql.com/doc/refman/5.0/en/case-statement.html order by case when updated is not null then updated else created end desc; /Kristian On Tue, Apr 8, 2008 at 1:04 PM, Richard <[EMAIL PROTECTED]> wrote: > Hello, > I've got a table which containes two date colomns. > The

Help with ORDER BY using two colomns

2008-04-08 Thread Richard
Hello, I've got a table which containes two date colomns. The first one is called `date` and the second `update` In the first one I put the ticket creation date, and on update I add or change the update value. So the update colomn does not contain a value until the first update has been done. I

Re: help with ORDER BY

2007-09-11 Thread Michael Dykman
Thing 1: your auto_increment key MUST be your primary key. Thing 2: the timestamp field will be updated with the current epochal timestamp which only increments every second.. as you have a timestamp field as you primary (and therefore unique) key, you will never be able to perform more than on

Re: help with ORDER BY

2007-09-11 Thread WiNK / Rob
Hi , I think i might have hit a bug, posted on forums.mysql.com but apparently nobody really reads that i think. my table: CREATE TABLE `clog` ( `cID` int(20) NOT NULL auto_increment, `lID` int(10) default NULL, `ip` int(10) default NULL, `timestamp` int(11) NOT NULL, PRIMARY KEY (`clickID`

help with ORDER BY

2007-09-11 Thread Pedro Mpa
Hi all! I need some help with ORDER BY in the following example. I want to order by selected category, then by subcategories of the selected category, then by categories with the same parent_id of the selected category, then by random if possible, or random within the categories if possible, but