|
Home > Archive > MySQL ODBC Connector > April 2005 > Ordering rows whit a select from where in ( exp )
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Ordering rows whit a select from where in ( exp )
|
|
| Adrian 2005-04-25, 3:23 am |
| ------ =_NextPart_000_0003_
01C54986.C1C7A8A0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi everyone,
Here is my issue:
I have this Query : SELECT field_name FROM meta WHERE id IN
('13','11','7','8','
9','10','12')
I want the rows to be display in the same order as the in list of
ids.Any ideas? Should I use order by? Whit witch option ?
Thanks for your help.
Adrian.
------ =_NextPart_000_0003_
01C54986.C1C7A8A0--
| |
| Johan Höök 2005-04-25, 3:23 am |
| -------------- 02040305000500080503
0300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi Adrian,
you can do
SELECT field_name FROM meta WHERE id IN
('13','11','7','8','
9','10','12')
ORDER BY FIELD(id,'13','11','
7','8','9','10','12'
)
/Johan
Adrian wrote:
>
>
> Hi everyone,
>
>
>
>
>
> Here is my issue:
>
>
>
> I have this Query : SELECT field_name FROM meta WHERE id IN
> ('13','11','7','8','
9','10','12')
>
>
>
> I want the rows to be display in the same order as the in list of
> ids.Any ideas? Should I use order by? Whit witch option ?
>
>
>
>
>
> Thanks for your help.
>
>
>
> Adrian.
>
>
>
>
-------------- 02040305000500080503
0300
Content-Type: text/plain; charset=us-ascii
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
-------------- 02040305000500080503
0300--
| |
| mathias fatene 2005-04-25, 3:23 am |
| Do that ,
SELECT field_name FROM meta WHERE id ='13'
Union
SELECT field_name FROM meta WHERE id ='11'
Union
SELECT field_name FROM meta WHERE id ='7'
Union
SELECT field_name FROM meta WHERE id ='8'
Union
SELECT field_name FROM meta WHERE id ='9'
Union
SELECT field_name FROM meta WHERE id ='10'
Union
SELECT field_name FROM meta WHERE id ='12'
Mathias
Best Regards
--------------------
Mathias FATENE
Hope that helps
*This not an official mysql support answer
-----Original Message-----
From: Adrian [mailto:adrian@kuwai
tnet.net]
Sent: lundi 25 avril 2005 10:06
To: mysql@lists.mysql.com
Subject: Ordering rows whit a select from where in ( exp )
Hi everyone,
Here is my issue:
I have this Query : SELECT field_name FROM meta WHERE id
IN
('13','11','7','8','
9','10','12')
I want the rows to be display in the same order as the in list
of ids.Any ideas? Should I use order by? Whit witch option ?
Thanks for your help.
Adrian.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
|
|
|
|
|