Re: [PHP-DB] IN clause

2007-06-26 Thread Chris

Bryan wrote:
If I have a SQL statement using the IN clause, how do I keep the order 
of the list?


Example:
SELECT * FROM table WHERE (number in (5, 9, 3, 4, 1, 7, 2, 8, 6))


Try

SELECT * FROM table WHERE (number in (5, 9, 3, 4, 1, 7, 2, 8, 6)) ORDER 
BY 5, 9, 3, 4, 1, 7, 2, 8, 6;


No idea if that will work ;)

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] IN clause

2007-06-26 Thread bedul
u can use array

put all your data into array.. example below


while($tmp=mysql_fetch_array($res)){
$myData[$tmp[0]]=$tmp[1];

}

ksort($myData);

foreach($myData as $nm=>$val){
//put your script here..

}
- Original Message -
From: "Bryan" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, June 26, 2007 8:01 PM
Subject: [PHP-DB] IN clause


> If I have a SQL statement using the IN clause, how do I
keep the order
> of the list?
>
> Example:
> SELECT * FROM table WHERE (number in (5, 9, 3, 4, 1, 7, 2,
8, 6))
>
> How would I pull records in the order of the numbers to
list out as:
> 5 - Record 5
> 9 - Record 9
> 3 - Record 3
> 4 - Record 4
> 1 - Record 1
> 7 - Record 7
> 2 - Record 2
> 8 - Record 8
> 6 - Record 6
>
> Thanks so much...
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] IN clause

2007-06-26 Thread Bryan
If I have a SQL statement using the IN clause, how do I keep the order 
of the list?


Example:
SELECT * FROM table WHERE (number in (5, 9, 3, 4, 1, 7, 2, 8, 6))

How would I pull records in the order of the numbers to list out as:
5 - Record 5
9 - Record 9
3 - Record 3
4 - Record 4
1 - Record 1
7 - Record 7
2 - Record 2
8 - Record 8
6 - Record 6

Thanks so much...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php