Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] change sequence of some records in query result ?
#1

[eluser]Zeeshan Rasool[/eluser]
hi ,
i have an array
$array = (
'0'=>'id',
'1'=>'name',
)
which holds records from a table but i need 2 records on top so i use order by clause and now one record in on 2nd and other is on 8th position in array.
How can i put then in first and second position ?
any function? thanks
#2

[eluser]mattpointblank[/eluser]
ORDER BY id=6, id=7, id ASC
#3

[eluser]Zeeshan Rasool[/eluser]
[quote author="mattpointblank" date="1257782390"]ORDER BY id=6, id=7, id ASC[/quote]
Thanks ! it really worked but with little changes ;-)
#4

[eluser]saidai jagan[/eluser]
can u pls explain this?
B cos i m eager to kno this. Big Grin
#5

[eluser]Zeeshan Rasool[/eluser]
[quote author="saidai jagan" date="1257786171"]can u pls explain this?
B cos i m eager to kno this. Big Grin[/quote]
Off course ! it depends on your query i used it in joins i need to take the 7th number of record to top and 11th to 2nd position so for that i use after my where clause:
Code:
order by id=7 Desc, id=11 desc
Simple : you can use like this.

Cheers.
#6

[eluser]saidai jagan[/eluser]
Great.
Thanks.
#7

[eluser]Zeeshan Rasool[/eluser]
Always welcome, my dear ;-)




Theme © iAndrew 2016 - Forum software by © MyBB