Ninth Dimension
08-21-2002, 02:30 PM
I've got a loop in my script that will find out a bunch of ID numbers, each of these numbers will need to be queried and the results pulled out of the database.
I could put a seperate query within each each loop to get the results, but this has two problems, first one is that it will create way too many queries on that page (up to 30 un-needed extra queries), and the second problem is that the results will be in reverse (because of the way the loop works, and the loop can't be reversed, that won't work).
what I promise to do insted is take all these ID, and run one query to get them all, and just have mysql put them into the order I want.
Problem is that I don't now what the query should look like :(
Below is an example of what I think it should look like to give you an idea of what I mean, maybe you can point me in the right direction?SELECT * FROM table WHERE id = 8,4,2,1(in this example I want it to pull id's 8, 4, 2 and 1)
Thanx
I could put a seperate query within each each loop to get the results, but this has two problems, first one is that it will create way too many queries on that page (up to 30 un-needed extra queries), and the second problem is that the results will be in reverse (because of the way the loop works, and the loop can't be reversed, that won't work).
what I promise to do insted is take all these ID, and run one query to get them all, and just have mysql put them into the order I want.
Problem is that I don't now what the query should look like :(
Below is an example of what I think it should look like to give you an idea of what I mean, maybe you can point me in the right direction?SELECT * FROM table WHERE id = 8,4,2,1(in this example I want it to pull id's 8, 4, 2 and 1)
Thanx