Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order by problem

Status
Not open for further replies.

JimFL

Programmer
Jun 17, 2005
131
GB
Hi,

Is there any way that I can optimse this query so that I return the order passed in by the mysql query.

The reason I am trying to do this is because I have already defined my order in a previous array function and I am passing in a string as a list of ID's


For example


SELECT xID FROM X1 x WHERE x.xID in(481,1,373,3,429,480,427,187,2,464,604,224,567,219,484,577,190,546) limit 0, 5

Can this be done within the same query or do I need to make a seperate temporary table and then use the order by function?

Would appreciate any help on this.

JimFl


 
Code:
SELECT xID 
  FROM X1 x 
 WHERE x.xID in (481,1,373,3,429,480,427,187
                ,2,464,604,224,567,219,484,577,190,546) 
order
    by field(xID,481,1,373,3,429,480,427,187
                ,2,464,604,224,567,219,484,577,190,546)  
limit 0, 5

r937.com | rudy.ca
 
Absoulutely what I was looking for - thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top