470,616 Members | 2,030 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,616 developers. It's quick & easy.

How do I get MySQL to NOT sort my resultset?

Hi All

The following query works, but MySQL sorts the results set:

SELECT STRINGTEXT FROM WEBSTRINGS WHERE GUI=0 AND LANGID='GB' AND TOKENID IN
(312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62, 63,87,88,89,90,208,210,249,309,310,311);

This means that when I grab this in my recordset the data for TOKENID 312 is
at the end rather than being the first one, eg

I expected my resultset to come back in the following order of requests:

312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,6 3,87,88,89,90,208,210,249,309,310,311

but it comes back as:

47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,87 ,88,89,90,208,210,249,309,310,311,312

Is there anyway to get MySQL to not do this for this query? I really need
them to come back as is.

Thanks

Laphan

Mar 12 '06 #1
1 1064
Laphan wrote:
Hi All

The following query works, but MySQL sorts the results set:

SELECT STRINGTEXT FROM WEBSTRINGS WHERE GUI=0 AND LANGID='GB' AND TOKENID IN
(312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62, 63,87,88,89,90,208,210,249,309,310,311);

This means that when I grab this in my recordset the data for TOKENID 312 is
at the end rather than being the first one, eg

I expected my resultset to come back in the following order of requests:

312,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,6 3,87,88,89,90,208,210,249,309,310,311

but it comes back as:

47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,87 ,88,89,90,208,210,249,309,310,311,312

Is there anyway to get MySQL to not do this for this query? I really need
them to come back as is.

Thanks

Laphan

One thing about SQL and databases - you do not know what order the data
is going to be returned - unless you specifically order it (ORDER BY)
but then you only get ASC or DESC.

So, your only option would be to read this into an array and select the
last member of the array first, then process the rest - and depending on
your programming language and your skill as a programmer, this could be
simple or quite challenging.

select...
order by tokenid asc;


Mar 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by somaBoy MX | last post: by
reply views Thread by Phil Powell | last post: by
5 posts views Thread by princevejita1 | last post: by
oll3i
5 posts views Thread by oll3i | last post: by
1 post views Thread by paulq182 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.