mysql order by

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

mysql order by

Post by hame22 »

Hi

I have a query:

Code: Select all

$result = mysql_query("Select * from venue_dir where moderated = 'Y' order by ven_enhanced DESC, ven_name ASC limit $offset, $limit ");
The results are ordered by whether or not they are enhanced and then if then in alphabetical order of their name.

What I would like to do is take the results that are enhanced and randomise their order.

Can this be done and how would I do it?

Thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't think you can do it in a single basic query. A union, maybe, if your MySQL version supports ordering in the sub-queries.
Post Reply