Hi
i have a news table. I am using the query "select * from news_table where news_id in(8,3,6,1)". This query is working properly. But the problem is i need to return the rows in the same order what we give in the 'in' clause. ie, first record with news_id 8 then 3 then 6 and so on...Is it possible? Pls help me...very urgent...

Recommended Answers

All 4 Replies

I think you should use order by clause. And if that does not fit your requirement then
you may put them in an array and do a loop using the array and fetch one by one row from the database.
GdLuck

I got it...I used the query

"SELECT * FROM `user` WHERE uid IN ( 22, 14, 18 )
ORDER BY FIELD( uid, 22, 14, 18 ) LIMIT 0 , 30";

Thank you

Thank you for replying.
I didn't know about this.
Good to know about your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.