At 20:00 -0800 3/11/02, George Marnellos wrote:
>Hi all,
>
>I'm executing the follow very simple type of query to select entries from a
>list:
>
>"select entryid, entryinfo from mytable where entryid in ('id7', 'id4',
>'id2', 'id5')"
>
>and, even though I don't specify any sorting order, MySQL sorts
>alphabetically
>by the field "entryid" (which happens to be an index), i.e. it returns
>
>+----------+-----------+
>| entryid  | entryinfo |
>+----------+-----------+
>| id2       |       ... |
>| id4      |       ... |
>| id5      |       ... |
>| id7      |       ... |
>+----------+-----------+
>
>I don't want this sorting order; I want the order to be that of the list. Is
>there a
>way to do this? It appears very simple but I cannot find how.

Use an ORDER BY clause that looks like this:

ORDER BY FIELD(entryid,'id7','id4','id2','id5')

>
>
>Thanks for any comments or help,
>George


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to