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
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(*)
- 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
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
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
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
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
>>>> 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
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
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
> -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,
> >
&
+-+
> | 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
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
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'
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
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
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
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:
> 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
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;
>
>
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
> 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(
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
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
---+
> | 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.
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
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
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
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
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
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..
.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
> 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
> 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
>
>
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!=""
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
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
|
+---+---+-+
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,
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).
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
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
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 |
+--
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:
> +---+---+-+
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 |
+---
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
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
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 |
> +--
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;
+--+
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."
---
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
Light
>>> 0.055
>>> %2008-11-11160 Green Light
>>> 0.065
>>> % 2008-11-12160 Green Light
>>> 0.115
>>> Is this possib
gt;> 0.055
>> %2008-11-11160 Green Light
>> 0.065
>> %2008-11-12160 Green Light
>> 0.115
>> Is this possible ?
>> On Fri, Oc
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
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
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
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
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
>
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
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.
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
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
' 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
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
- 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
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
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
>-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
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
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]&
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 |
+--+-+
|
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
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)
>
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
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/
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
> 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
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
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
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
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
[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
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
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
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 |
|
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 |
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
*, 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 |
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 |
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
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 |
|
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
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,
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
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
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
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)
=
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
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
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
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 - 100 of 1013 matches
Mail list logo