Re: ORDER BY not using index?

2015-07-18 Thread yoku ts.
perhaps assist with the below... I'm not sure at all why my > index aren't being used for the ORDER BY. Currently some 443K records in > the table, but this will grow to a good few million. I simply cannot, > afford a filesort. > > > mysql> SELE

ORDER BY not using index?

2015-07-18 Thread Chris Knipe
Hi, Can someone perhaps assist with the below... I'm not sure at all why my index aren't being used for the ORDER BY. Currently some 443K records in the table, but this will grow to a good few million. I simply cannot, afford a filesort. mysql> SELECT COUNT(*)

Re: using LIMIT without ORDER BY

2012-12-13 Thread Johan De Meersman
- Original Message - > From: "Akshay Suryavanshi" > I was referring to a condition when there is no index on the tables, > not even primary keys. If you have a lot of data in there, may I suggest you (temporarily) add a unique index and benchmark both methods? As I said, limit n,m is th

Re: using LIMIT without ORDER BY

2012-12-13 Thread Akshay Suryavanshi
etera. > > The ONLY way to ensure consecutive queries return your data in the same > order, is specifying an order by clause. > > Apart from that, I personally prefer to avoid the limit 0,10 /limit 11/20 > technique, because a) rows might have gotten inserted and/or deleted, a

Re: using LIMIT without ORDER BY

2012-12-13 Thread Johan De Meersman
utive queries return your data in the same order, is specifying an order by clause. Apart from that, I personally prefer to avoid the limit 0,10 /limit 11/20 technique, because a) rows might have gotten inserted and/or deleted, and b) limit is applied to the full resultset. Instead, order by

Re: using LIMIT without ORDER BY

2012-12-12 Thread Akshay Suryavanshi
There's a confusion. I want to get all the data in table t by pages, using > Limit SQL without ORDER BY: > SELECT * FROM t Limit 0,10 > SELECT * FROM t Limit 10, 10 > ... > > Is it right without ORDER BY? > Is there any default order in table t, to make suer I can get all data i

RE: UNION and ORDER BY

2012-06-21 Thread Rick James
The parens are for making sure the parsing works correctly. Probably either one works fine. Suggest you do EXPLAIN EXTENDED ...; SHOW WARNINGS; I suspect that the output from each will be identical, and have more parens. The main need for parens is to avoid associating the ORDER BY with

UNION and ORDER BY

2012-06-21 Thread Hal�sz S�ndor
>>>> 2012/06/20 14:32 -0700, Rick James >>>> ( SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid1=xxx UNION SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid2=xxx ) ORDER BY overlap DESC; Make it UNION ALL or UNION DISTINCT depending on whether xxx can be in

RE: Help with ORDER BY

2011-02-07 Thread Rolando Edwards
SELECT name, city, state, phone, prods_done, cancels, miles FROM (SELECT name, city, state, phone, prods_done, cancels, miles, ((prod_done - cancels) * 100 / prod_done) reliability FROM volunteer_search WHERE project_id = 5653) A ORDER BY reliability DESC, miles ASC Give it a try !!! Rolando A

Help with ORDER BY

2011-02-07 Thread Richard Reina
ct_id = 5653 ORDER BY miles ASC, cancels/(prods_done/cancels) ASC, prods_done DESC"; The results look something like this: Jim Barnes Chicago, IL 773-555- 2 1 11.5 Kelley Smith Cicero, IL 708-444-2121 3 0 21.6 Kim Ayers Plainfield, IL 630-888-9898 22 1 25.1 I am trying to find a w

RE: Order by "in" clause

2010-11-09 Thread Daevid Vincent
> -Original Message- > From: Joeri De Backer [mailto:fons...@gmail.com] > Sent: Tuesday, November 09, 2010 1:16 AM > To: mysql > Subject: Re: Order by "in" clause > > On Tue, Nov 9, 2010 at 10:09 AM, Mark Goodge > wrote: > > Hi, > > &

Re: Order by "in" clause

2010-11-09 Thread Joeri De Backer
+-+ > |   5  | wibble  | > +--+-+ > |   1  | flirble | > +--+-----+ > > Is this possible? If so, how? > select * from product where id in (10,3,8,5,1) order by field(id,10,3,8,5,1) should do the trick... Regards, Joeri -- MySQL General Mailing Lis

Order by "in" clause

2010-11-09 Thread Mark Goodge
Hi, I have a query like this: select id, title from product where id in (1,3,5,8,10) What I want it to do is return the rows in the order specified in the "in" clause, so that this: select * from product where id in (10,3,8,5,1) will give me results in this order: +--+-+ | id

RE: ORDER BY with field alias issue

2010-09-29 Thread Daevid Vincent
Easy. SELECT DATE_FORMAT(`Time`, '%h:%i%p') as `Time_Format` FROM `reservation` ORDER BY `Time` > -Original Message- > From: BMBasal [mailto:bmb37...@gmail.com] > Sent: Wednesday, September 29, 2010 3:50 PM > To: 'Chris W'; 'MYSQL General List'

RE: ORDER BY with field alias issue

2010-09-29 Thread BMBasal
It is inherent in your naming. As long as your alias "time" is the same as the column name "time", MySQL will have no way to distinguish which one you refers to exactly in your order-by clause, and chooses the alias in the select-clause as the one you intended. You confused My

Re: ORDER BY with field alias issue

2010-09-28 Thread Johnny Withers
Order by reservation.time JW On Tuesday, September 28, 2010, Chris W <4rfv...@cox.net> wrote: >  I have the following query that is giving me problems. > > SELECT DATE_FORMAT(`Time`, '%h:%i%p') as `Time` > FROM `reservation` > ORDER BY `Time` > > Problem

ORDER BY with field alias issue

2010-09-28 Thread Chris W
I have the following query that is giving me problems. SELECT DATE_FORMAT(`Time`, '%h:%i%p') as `Time` FROM `reservation` ORDER BY `Time` Problem is it sorts wrong because of the date format function output with am and pm. I guess I should have named things differently but I wo

RE: ORDER BY LIMIT issue

2010-08-04 Thread Jerry Schwartz
n Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: je...@gii.co.jp Web site: www.the-infoshop.com >-Original Message- >From: Kristian Davies [mailto:kristian.dav...@gmail.com] >Sent: Wednesday, August 04, 2010 5:03 AM >To: mysql@lists.mysql.com >Subject:

Re: ORDER BY LIMIT issue

2010-08-04 Thread Kristian Davies
> Isn't it so that it firstly order the rows by id (index'ed?) and then scan >  it to pick the rows which satisfy the where clause? > > It stops when the result reaches the limit, otherwise scans the whole (27, > 000 rows scan). > > Then the response time with 2 rows limit by 2 can really depend. I

Re: ORDER BY LIMIT issue

2010-08-04 Thread Eigo Mori
Hi, > With the following query if I it returns 2 results it's fast .04s, if > it has less results than the limit it takes 1minute. > > Query: > select * from hub_dailies_sp where active='1' and date='2010-08-04' > order by id desc LIMIT 2; > >

ORDER BY LIMIT issue

2010-08-04 Thread Kristian Davies
With the following query if I it returns 2 results it's fast .04s, if it has less results than the limit it takes 1minute. Query: select * from hub_dailies_sp where active='1' and date='2010-08-04' order by id desc LIMIT 2; Show create table: http://pastebin.org/447

Re: order by numeric value

2010-04-28 Thread Martijn Tonies
> But I'd prefer not to see the extra sorting field. You don't need to select a field in order to be able to order by it. So select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_entries.debit),0),2)) as Debit, concat(

Re: order by numeric value

2010-04-27 Thread Keith Clark
On Wed, 2010-04-28 at 08:57 +1000, Jesper Wisborg Krogh wrote: > On Wed, 28 Apr 2010 08:53:57 Keith Clark wrote: > > But I'd prefer not to see the extra sorting field. > > You don't need to select a field in order to be able to order by it. > > So > > se

Re: order by numeric value

2010-04-27 Thread Jesper Wisborg Krogh
On Wed, 28 Apr 2010 08:53:57 Keith Clark wrote: > But I'd prefer not to see the extra sorting field. You don't need to select a field in order to be able to order by it. So select chart_of_accounts.accountname as Account, concat('$',format(coalesce(sum(sales_journal_e

RE: order by numeric value

2010-04-27 Thread Keith Clark
---+ > | 1.00 | > +---+ > 1 row in set (0.00 sec) > > > Which in that case, it's better to just select balance without the dollar > sign and order on that column.

RE: order by numeric value

2010-04-27 Thread Gavin Towey
er on that column. Regards, Gavin Towey -Original Message- From: DaWiz [mailto:da...@dawiz.net] Sent: Tuesday, April 27, 2010 3:46 PM To: Keith Clark; mysql@lists.mysql.com Subject: Re: order by numeric value Try order by CAST(Balance as decimal(8,2)) asc; Cast will work in the order b

Re: order by numeric value

2010-04-27 Thread DaWiz
Try order by CAST(Balance as decimal(8,2)) asc; Cast will work in the order by. Glenn Vaughn - Original Message - From: "Keith Clark" To: Sent: Tuesday, April 27, 2010 3:52 PM Subject: order by numeric value I have the following statement: select chart_of_accounts.a

Re: order by numeric value

2010-04-27 Thread Keith Clark
t; > from sales_journal_entries > > left join sales_journal > > on sales_journal.journalID=sales_journal_entries.journalID > > left join chart_of_accounts > > on chart_of_accounts.accountID=sales_journal_entries.accountID > > where sales_journal.date > '2008-12-31' > > and s

Re: order by numeric value

2010-04-27 Thread Carsten Pedersen
ournal_entries.accountID where sales_journal.date > '2008-12-31' and sales_journal.date < '2010-01-01' group by sales_journal_entries.accountID order by Balance asc; and I'd like the output to be sorted by the Balance according to the numberic value, but it is sorting by the

order by numeric value

2010-04-27 Thread Keith Clark
ere sales_journal.date > '2008-12-31' and sales_journal.date < '2010-01-01' group by sales_journal_entries.accountID order by Balance asc; and I'd like the output to be sorted by the Balance according to the numberic value, but it is sorting by the string resul

order by-- rollup

2010-02-06 Thread MuraliKrishna
Hi how to use "order by" with "with rollup", if it is not possible is there any alternative, in rollup how to name the null. is there chance to do so. please help me with this..

ORDER BY favours full scan over a faster filesort

2009-12-21 Thread Oscar
.role_id=2556 order by item0_.id desc; mysql version: 5.1.34 have you guys met this problem? thanks, -Oscar -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org

Re: Bug? Distinct AS with Order By

2009-10-22 Thread Glyn Astill
> From: Glyn Astill > > Doesn't look crazy to me, and it works in 5.0.32 > > http://www.privatepaste.com/50RvhihKKm > > Perhaps time to patch that server ... > I've guessed at the table def there, obviously your def may be different and that would surely affect the palanners choice. Perhaps

Re: Bug? Distinct AS with Order By

2009-10-22 Thread Glyn Astill
> From: Matt Neimeyer > > Generic code to draw a SELECT element on the screen > sometimes it ends > up like such... > > SELECT DISTINCT name AS myvalue,name AS mydisp FROM names > WHERE > name!="" ORDER BY myvalue > > On 4.1.22 this returns > >

Bug? Distinct AS with Order By

2009-10-22 Thread Matt Neimeyer
I'm not sure what to search on to see if someone has reported this as a bug or if I'm doing something wrong... Generic code to draw a SELECT element on the screen sometimes it ends up like such... SELECT DISTINCT name AS myvalue,name AS mydisp FROM names WHERE name!=""

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Basil Daoust
head-row follewed by the group members with that head (2)head rows are ordered alphabetically by name. What the query looks like? Thanks I hope this is not a school assignment. What I came up with was to create a new order column that I populated with the name of the HEAD. Then I can order by

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Brent Baisley
ame is the current record, sometimes it's a "parent" record, you need to conditional check which type of "record" it is and built the sort value. SELECT tablename.*, IF(tablename.head_id=NULL, CONCAT(tablename.name, tablename.member_id), CONCAT(heads.name, table

Re: Hard? query to with group order by group head's name

2009-07-21 Thread Elim PDT
| +---+---+-+ which not groups correctly. Seems it's a hard query. - Original Message - From: "Darryle Steplight" To: "Elim PDT" Cc: Sent: Wednesday, July 15, 2009 11:50 PM Subject: Re: Hard? query to with group order by group head's name Hi Elim,

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Marcus Bointon
On 16 Jul 2009, at 15:26, Govinda wrote: Meaning that on a shared hosting situation, without ssh, then I cannot do that, right? Not necessarily - you can run the client locally and connect to the remote DB. It depends if your host allows remote access to mysql (they might do on request).

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Marcus Bointon
On 16 Jul 2009, at 15:02, Govinda wrote: I see such nice formated text output serving to illustrate people's tables and I think it must be due to some code which is spitting that out, rather than people typing so painstakingly. What is that function/MySQL/code? It's the default output f

Re: what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Govinda
I see such nice formated text output serving to illustrate people's tables and I think it must be due to some code which is spitting that out, rather than people typing so painstakingly. What is that function/MySQL/code? It's the default output format of the mysql command line client, no

what outputs/illustrates a table's structure? - WAS: Re: Hard? query to with group order by group head's name

2009-07-16 Thread Govinda
My table group_member looks like this: +---+---+-+ | member_id | name | head_id | +---+---+-+ | 1 | Elim |NULL | | 2 | Ann | 1 | | 3 | David |NULL | | 4 | John | 3 | | 5 | Jane | 3 | +--

Re: Hard? query to with group order by group head's name

2009-07-15 Thread Darryle Steplight
Hi Elim, I didn't test it out but it sounds like you want to do this " SELECT * FROM group_members GROUP BY head_id, member_id ORDER BY name ASC ". On Thu, Jul 16, 2009 at 1:20 AM, Elim PDT wrote: > My table group_member looks like this: > +---+---+-+

Hard? query to with group order by group head's name

2009-07-15 Thread Elim PDT
My table group_member looks like this: +---+---+-+ | member_id | name | head_id | +---+---+-+ | 1 | Elim |NULL | | 2 | Ann | 1 | | 3 | David |NULL | | 4 | John | 3 | | 5 | Jane | 3 | +---

Re: ignore accents in order by

2009-06-12 Thread Isart Montane
I agree with Per, I use utf8 and it works fine for me, even with Chinese characters On Fri, Jun 12, 2009 at 8:40 AM, Per Jessen wrote: > PJ wrote: > > > Let me put it this way, I am not having the problem. The problem seems > > to be withthe way that character encoding is set up on the internet

Re: ignore accents in order by

2009-06-12 Thread Per Jessen
PJ wrote: > Let me put it this way, I am not having the problem. The problem seems > to be withthe way that character encoding is set up on the internet - > as confused and inconsistent as most everything else. > You can put whatever charset you want in the header, in the collations > in your data

Re: ignore accents in order by

2009-06-11 Thread PJ
Isart Montane wrote: > Hi, > > I'm not having any problem on my local computer > > mysql> select text,text2 from table1 order by text2 desc; > +--+---+ > | text | text2 | > +--+---+ > | a   |    1 | > | �   |    0 | > +--

Re: ignore accents in order by

2009-06-11 Thread Isart Montane
Hi, I'm not having any problem on my local computer mysql> select text,text2 from table1 order by text2 desc; +--+---+ | text | text2 | +--+---+ | a| 1 | | �| 0 | +--+---+ mysql>select text,text2 from table1 order by text2 desc; +--+

ignore accents in order by

2009-06-11 Thread PJ
Is there a way to order lists while ignoring the accents? So far, I have found nothing simple; and I need to keep the accents for output. The language is French (and québécois) :-) TIA -- Hervé Kempf: "Pour sauver la planète, sortez du capitalisme." ---

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi Basically from the query below, it would only return one product like RedLight. But I need to return a list of all products, ordered by a SELECT ProductID, ProductName, AVG(ProductScore * Quantity) AS a FROM Products GROUP BY ProductID ORDER BY a DESC On Fri, Oct 24, 2008 at 2:53 PM

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
Light >>> 0.055 >>> %2008-11-11160 Green Light >>> 0.065 >>> % 2008-11-12160 Green Light >>> 0.115 >>> Is this possib

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
gt;> 0.055 >> %2008-11-11160 Green Light >> 0.065 >> %2008-11-12160 Green Light >> 0.115 >> Is this possible ? >> On Fri, Oc

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
ECTED]>wrote: > >> SELECT ProductID, >> ProductName, >> AVG(ProductScore * Quantity) AS a >> FROM Products >> GROUP BY ProductID >> ORDER BY a DESC >> >> 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: >>> >>> Following on

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
wrote: > SELECT ProductID, > ProductName, > AVG(ProductScore * Quantity) AS a > FROM Products > GROUP BY ProductID > ORDER BY a DESC > > 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: > >> Following on from my email below I now need help with the following

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
SELECT ProductID, ProductName, AVG(ProductScore * Quantity) AS a FROM Products GROUP BY ProductID ORDER BY a DESC 2008/10/24, Tompkins Neil <[EMAIL PROTECTED]>: > > Following on from my email below I now need help with the following > problem. Here is a list of my sampl

Re: ORDER BY Help

2008-10-24 Thread Tompkins Neil
wrote: > Thanks for the reply, this is exactly what I wanted. > > Cheers Olexandr ! > > On Fri, Oct 24, 2008 at 1:26 PM, Olexandr Melnyk <[EMAIL PROTECTED]>wrote: > >> SELECT ProductName FROM Products >> WHERE ProductScore > 100 >> ORDER BY CASE WHEN

Re: ORDER BY Help

2008-10-24 Thread Olexandr Melnyk
SELECT ProductName FROM Products WHERE ProductScore > 100 ORDER BY CASE WHEN ProductScore = 125 THEN 0 ELSE 1 END, ProductScore But this query won't use an index, so it would be a good idea to do this in two queries 2008/10/24 Tompkins Neil <[EMAIL PROTECTED]> > Hi >

ORDER BY Help

2008-10-24 Thread Tompkins Neil
Hi I've the following basic query like SELECT ProductName FROM Products WHERE ProductScore > 100 ORDER BY ProductScore However, how can I order by ProductScore, but ensure the product with ID 125 is at the top ? Is this possible. Thanks Neil

Re[5]: SELECT DISTINCT with ORDER BY implementation

2008-09-30 Thread Andrew Aksyonoff
Hello Michael, Tuesday, September 30, 2008, 8:00:36 PM, you wrote: Andrew>> However if the specific sorting algorithm is not stable it *might* MW> It's not stable; MySQL is using several different technics to MW> calculate GROUP BY and may thus return the rows in any order within MW> the group by.

Re[4]: SELECT DISTINCT with ORDER BY implementation

2008-09-30 Thread Michael Widenius
ort the sub-select result by outer GROUP BY instead of inner >>> ORDER BY. If that sorting is stable, this should work, but can we rely SP> Yes. This is documented behavior: SP> http://dev.mysql.com/doc/refman/5.0/en/select.html : SP> "If you use GROUP BY, output rows are

Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
On Fri, Jul 25, 2008 at 12:35 PM, Arthur Fuller <[EMAIL PROTECTED]> wrote: > ORDER BY implies a sort of the result set. I don't think there is any way > around that. I guess so. What I am doing is to just run the query once per day and store the results in memcache. Michael

Re: Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Rob Wultsch
' AND > Country != 'United States' > AND Country != ' ' > AND Country IS NOT NULL ) > GROUP BY Country > ORDER BY Cnt > DESC LIMIT > > This is a costly query I suggest that this is not a well normalized. I suggest that at a min

Optimizing GROUP BY and ORDER BY

2008-07-25 Thread Michael Stearne
I have a query: SELECT Country, COUNT( Country ) AS Cnt FROM properties WHERE ( Country != 'USA' AND Country != 'US' AND Country != 'Unit' AND Country != 'United States' AND Country != ' ' AND Country IS NOT NULL ) GROUP BY Country ORDER BY Cnt

Re: ORDER BY problem

2008-07-11 Thread Obantec Support
- Original Message - Subject: RE: ORDER BY problem Try your query with either back quotes around Company SELECT * FROM Contacts WHERE Categories="Services" and BusinessCodes REGEXP "^R" and gold_id="2" ORDER BY `Company` ASC Or no quotes around C

RE: ORDER BY problem

2008-07-11 Thread Rolando Edwards
Try your query with either back quotes around Company SELECT * FROM Contacts WHERE Categories="Services" and BusinessCodes REGEXP "^R" and gold_id="2" ORDER BY `Company` ASC Or no quotes around Company SELECT * FROM Contacts WHERE Categories="Services" a

ORDER BY problem

2008-07-11 Thread Obantec Support
Hi while testing an upgrade from 3.23.58 to 4.1.22 on an FC3 test box SELECT * FROM Contacts WHERE Categories="Services" and BusinessCodes REGEXP "^R" and gold_id="2" ORDER BY "Company" ASC on mysql server3.23.58 i get company result in ASC order. on

RE: force row to appear at top of results using order by

2008-07-01 Thread Jerry Schwartz
>-Original Message- >From: Andrew Martin [mailto:[EMAIL PROTECTED] >Sent: Tuesday, July 01, 2008 9:20 AM >To: mysql@lists.mysql.com >Subject: force row to appear at top of results using order by > >Hello, > >I have an order by question... > >This is t

RE: force row to appear at top of results using order by

2008-07-01 Thread Rolando Edwards
SELECT events_groups_id, events_groups_name FROM events_groups ORDER BY IF(events_groups_id=1,0,1),events_groups_name ASC; -Original Message- From: Andrew Martin [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2008 9:20 AM To: mysql@lists.mysql.com Subject: force row to appear at top of

Re: force row to appear at top of results using order by

2008-07-01 Thread Andrew Martin
Many thanks for the quick replies! This solution appears the most elegant: -- Forwarded message -- From: Markus Grossrieder <[EMAIL PROTECTED]> Date: 2008/7/1 Subject: Re: force row to appear at top of results using order by To: Andrew Martin <[EMAIL PROTECTED]&

force row to appear at top of results using order by

2008-07-01 Thread Andrew Martin
Hello, I have an order by question... This is the "raw" data... mysql> SELECT events_groups_id, events_groups_name FROM events_groups; +--+-+ | events_groups_id | events_groups_name | +--+-+ |

Re: GROUP & ORDER BY Question

2008-05-22 Thread Peter Brawley
of the top details. SELECT Description LongDescription Detail SUM(Volume) FROM StatsTable GROUP BY Description LongDescription Detail ORDER BY SUM(Volume) DESC LIMIT 100 What I believe would work is a function in MySQL that is equivalent to the CUBE function in Oracle. Any

Re: GROUP & ORDER BY Question

2008-05-21 Thread Rob Wultsch
ery to is the top 100 details ordered by > SUM(Volume) DESC for each unique LongDescription > This is what I am trying now but its not quite correct, it simply returns > 100 of the top details. > > SELECT >Description >LongDescription >Detail > SUM(Volume) >

GROUP & ORDER BY Question

2008-05-21 Thread David Perron
of the top details. SELECT Description LongDescription Detail SUM(Volume) FROM StatsTable GROUP BY Description LongDescription Detail ORDER BY SUM(Volume) DESC LIMIT 100 What I believe would work is a function in MySQL that is equivalent to the CUBE function in Oracle. Any

Re: Age old order by rand() issue

2008-05-02 Thread Rob Wultsch
g USING (aka =) rather than >= . You were also doing a WHERE clause on that could have removed the random result. My only problem with what you are using is that it is more likely to give a large results than a small one. Take a look at the http://jan.kneschke.de/projects/mysql/order-by-rand/

Re: Age old order by rand() issue

2008-05-02 Thread Scott Haneda
I have seen nicer fast random row implement, but that will work. Do you happen to have a snip of it, the one I have seems to lean pretty heavy as far as I can tell, and on occasion, though rare, also sends me an empty result set. -- Scott [EMAIL PROTECTED] -- MySQL General Mailing List F

Re: Age old order by rand() issue

2008-05-01 Thread Rob Wultsch
> SELECT storage_path, image_md5, id > FROM images > JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM images WHERE approved = > 1)) AS id) AS r2 USING (id) >WHERE approved = 1; > > I really do not get this, SELECT CEIL(RAND() will always return 1 will it > not? Any idea why I get an empty

Re: Age old order by rand() issue

2008-05-01 Thread Rob Wultsch
Hi, Responses inline On Thu, May 1, 2008 at 3:11 PM, Scott Haneda <[EMAIL PROTECTED]> wrote: > List search seems to return 0 results, and I am a bit stumped. > > Getting a more optimized order by random with 1 record... > I found a snip online that works, but seems to

Age old order by rand() issue

2008-05-01 Thread Scott Haneda
List search seems to return 0 results, and I am a bit stumped. Getting a more optimized order by random with 1 record... I found a snip online that works, but seems to return an empty on occasion, and I am not sure why: SELECT storage_path, image_md5, id FROM images JOIN (SELECT CEIL(RAND

Re: Odd Results on Mysql LIMIT and ORDER BY

2008-04-26 Thread Brent Baisley
You may want to check on the version you are running. There have been a few odd bugs in various MySQL versions in regards to limits and order by filtering. Although it usually involved joins and/or unions. If you can't or don't want to upgrade your MySQL version, you can try res

Odd Results on Mysql LIMIT and ORDER BY

2008-04-26 Thread j's mysql general
01 sec) And I have queries like these: select * from containers where upload_date < 1209208414 and category_id = 120 order by upload_date desc limit 0,25 and select * from containers where upload_date < 1209208414 and category_id = 120 order by upload_date desc limit 175,25 These queri

Re: Weird result on max compared to order by

2008-04-22 Thread Sebastian Mendel
[EMAIL PROTECTED] schrieb: Hi, I did a select on a primary key.. Select max(account_id) from mytable; -- it gave me a value X I did a select with order by Select account_id from mytable order by account_id desc limit 3 -- it gave me a value of Y ( Y is the

Weird result on max compared to order by

2008-04-22 Thread jmacaranas
Hi, I did a select on a primary key.. Select max(account_id) from mytable; -- it gave me a value X I did a select with order by Select account_id from mytable order by account_id desc limit 3 -- it gave me a value of Y ( Y is the right value ) I was

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

2008-04-08 Thread Richard
solution, like storing the order field permanetly and giving it an index :) Ben Richard wrote: 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_tab

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

2008-04-08 Thread Ben Clewett
pdate != '', 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 || 50 | | 4 | 30 || 30 | |

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

2008-04-08 Thread Andy Wallace
etly and giving it an index :) Ben Richard wrote: 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 |

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

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

2008-04-08 Thread Richard
*, 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 || 50 | | 4 | 30 |

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

2008-04-08 Thread 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 | 100 | | 2 | 10 | 60 |

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 | 4

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 | |

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 th

Re: Help with ORDER BY using two colomns

2008-04-08 Thread Richard
ocess.). I hope my explanation in understadable ... :) Rafael Barbolo Lopes a écrit : 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,

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 w

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` DE

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

Help with ORDER BY using two colomns

2008-04-08 Thread Richard
ne. I would like to order the tickets by their last update value. And if this value does not exist use the date value. at the moment I use this : ORDER BY `date` DESC" and I would like to replace it by something like this : ORDER (IF `update`!= '' BY UPDATE ELSE BY DATE)

RE: ORDER BY calculated field

2008-03-20 Thread Neil Tompkins
= ProductsPurchases.ProductIDGROUP BY Products.ProductID ORDER BY varProductCount DESC > Date: Thu, 20 Mar 2008 13:08:51 +0100> From: [EMAIL PROTECTED]> CC: > mysql@lists.mysql.com> Subject: Re: ORDER BY calculated field> > Neil > Tompkins schrieb:> > Thanks Sebastian, but I now get the

RE: ORDER BY calculated field

2008-03-20 Thread Neil Tompkins
Thanks Sebastian, but I now get the error message [MySQL][ODBC 3.51 Driver][mysqld-3.23.58]Invalid use of group function > Date: Thu, 20 Mar 2008 12:59:22 +0100> From: [EMAIL PROTECTED]> To: > mysql@lists.mysql.com> Subject: Re: ORDER BY calculated field> > Sebast

Re: ORDER BY calculated field

2008-03-20 Thread Sebastian Mendel
Neil Tompkins schrieb: Thanks Sebastian, but I now get the error message [MySQL][ODBC 3.51 Driver][mysqld-3.23.58]Invalid use of group function i am not familiar with ODBC or MySQL 3.x but possible just GROUP BY is missing check the manual for your mysql version for the exact syntax if this

Re: ORDER BY calculated field

2008-03-20 Thread Sebastian Mendel
Sebastian Mendel schrieb: Neil Tompkins schrieb: Hi I want to order by the totalled fields varProductCount and Products.ProductReviewDESC just put them together, separated with comma, like it is written in the manual ORDER BY varProductCount + Products.ProductReviewDESC, COUNT

  1   2   3   4   5   6   7   8   9   10   >