hi.sorry to borther again
I want to ask how to rewrite those statement ,too.
Like '>,<,LIMIT '.
And when I use 'order by ' how to change the order of 'ASC,DESC'?
Thanks very much.
vanessa lee
-----Original Message-----
From: Roan Kattouw <roan.kattouw(a)gmail.com>
To: Wikimedia developers <wikitech-l(a)lists.wikimedia.org>
Date: Thu, 26 Nov 2009 13:32:10 +0100
Subject: Re: [Wikitech-l] SQL
2009/11/26 Tim Starling <tstarling(a)wikimedia.org>rg>:
Don't use subselects, they're not supported by
MySQL 4.0 which is what
we target.
$dbr = wfGetDB( DB_SLAVE );
$max = $dbr->selectField(
'recentchanges',
'max(rc_id)',
false,
__METHOD__,
array( 'GROUP BY' => 'rc_title' );
$res = $dbr->select(
'recentchanges',
'*',
array(
'rc_id' => $max,
'rc_namespace' => 0,
'rc_title' => 'Wiki',
),
__METHOD__ );
Note that the GROUP BY condition in the first query is unnecessary,
and that the whole thing could be rewritten to SELECT * FROM
recentchanges WHERE rc_namespace=0 AND rc_title='Wiki' ORDER BY rc_id
DESC LIMIT 1;
Roan Kattouw (Catrope)
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l