niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » MySQL
mysql order question
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Dan Buettner
*nix forums Guru Wannabe


Joined: 13 Oct 2005
Posts: 119

PostPosted: Wed Jul 19, 2006 8:13 pm    Post subject: Re: mysql order question Reply with quote

Not sure there's a good way to do that ... here's one possible solution:

create a little extra table like so:

create table mytemptable
(mytemptable_id int not null auto_increment primary key,
table_id int,
key table_id_idx (table_id));

then insert your values for your IN clause into 'mytemptable' in the
proper order,
then issue a query that joins on that table and orders by the ID
number of the temp table:

select t.*
from table t, mytemptable mtt
where t.id = mtt.table_id
order by mtt.mytemptable_id

And finally delete your entries from your extra table so the next
query is accurate.

Not pretty eh?

Dan


On 7/19/06, OKAN ARI <liste@ari-tech.com> wrote:
Quote:
I have a sql query like SELECT * FROM table WHERE id IN (4,88,23);
Result order in ID is: 4,23,88

But I need to receive result in order 4,88,23. So how can I manage to receive result in order LIKE IN() clause?

regards, okan


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org
Back to top
OKAN ARI
*nix forums beginner


Joined: 16 Sep 2005
Posts: 8

PostPosted: Wed Jul 19, 2006 7:03 pm    Post subject: mysql order question Reply with quote

I have a sql query like SELECT * FROM table WHERE id IN (4,88,23);
Result order in ID is: 4,23,88

But I need to receive result in order 4,88,23. So how can I manage to receive result in order LIKE IN() clause?

regards, okan
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Dec 04, 2008 1:42 am | All times are GMT
navigation Forum index » Databases » MySQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts postfix smtp authentication using mysql stored user/pass rtresidd Postfix 0 Fri Oct 03, 2008 5:58 am
No new posts Postfix + MySQL error: very strange variable %s iWarior Postfix 0 Mon Aug 25, 2008 2:01 pm
No new posts Newbie question: How to forward a domain to a mailbox? leei Postfix 0 Fri Aug 24, 2007 4:55 pm
No new posts Anyone managed to install policyd on x86_64 and mySQL 5.0x? SupaDucta Postfix 5 Mon Nov 13, 2006 3:18 am
No new posts postfix dovecot mysql issues gnetcon Postfix 0 Thu Aug 03, 2006 9:19 pm

Credit Cards | Internet Advertising | Remortgages | Credit Cards | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1950s ][ Queries: 20 (0.1221s) ][ GZIP on - Debug on ]