MySQL Forums
Forum List  »  Docs

Re: Lack of "real" example makes it very dificult to understand!
Posted by: Stefan Hinz
Date: August 08, 2004 09:42PM

V@no wrote:

> > PS - what's the question you've been trying
> > to get an answer for?

> Well, I couldnt find any solution for the task I'm
> trying to acomplish as discribed on this forum:
> http://forums.devshed.com/showthread.php?p=745159&;
> amp;posted=1

OK, so your question was: "is there any way select entries (sorted by whatever) but have one/two/three specific entries be always first in the list?"

As other users on devshed have pointed out, you could do that using one SQL query only, but that query would look pretty daunting. I'd suggest to use two queries instead, and assemble the results using PHP or whatever web programming language you are using. The queries would look like this (assuming 10, 20, and 30 are the message IDs that you would always want to retrieve:

SELECT messageID, ... FROM tbl WHERE messageID IN(10,20,30)

SELECT messageID, ... FROM tbl ... ORDER BY sortField (ASC | DESC)

Stefan Hinz, MySQL Documentation, Berlin, Germany

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Lack of "real" example makes it very dificult to understand!
2755
August 08, 2004 09:42PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.