473,288 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,288 software developers and data experts.

force order

I'm working on a web page in php with a mysql DB. I'm trying to list
some products with some other information but I'm having trouble tying
them together. Is there a way to force a very specific order to be
returned? What I need to be able to do is have a query like

"select * from products where prodID = 'thing1' or prodID = 'thing2'
or prodID = 'thing3'...

but I need it to come back in that EXACT order, product matching
thing1 first thing2 second and so on.

Any ideas?

Thanks,
Tim
Jul 19 '05 #1
3 2470
Odarr wrote:
I'm working on a web page in php with a mysql DB. I'm trying to list
some products with some other information but I'm having trouble tying
them together. Is there a way to force a very specific order to be
returned? What I need to be able to do is have a query like

"select * from products where prodID = 'thing1' or prodID = 'thing2'
or prodID = 'thing3'...

but I need it to come back in that EXACT order, product matching
thing1 first thing2 second and so on.


use:
order by fieldname
at the end of your query.

Instead of names, use integer id values in the field which you want to
use for ordering, that way you can easily deside that 'thing1' = 1,
'thing2' = 2, etc, and ordering them is simple and fast.

Jul 19 '05 #2
Odarr wrote:
I'm working on a web page in php with a mysql DB. I'm trying to list
some products with some other information but I'm having trouble tying
them together. Is there a way to force a very specific order to be
returned? What I need to be able to do is have a query like

"select * from products where prodID = 'thing1' or prodID = 'thing2'
or prodID = 'thing3'...

but I need it to come back in that EXACT order, product matching
thing1 first thing2 second and so on.


use:
order by fieldname
at the end of your query.

Instead of names, use integer id values in the field which you want to
use for ordering, that way you can easily deside that 'thing1' = 1,
'thing2' = 2, etc, and ordering them is simple and fast.

Jul 19 '05 #3
Odarr wrote:
I'm working on a web page in php with a mysql DB. I'm trying to list
some products with some other information but I'm having trouble tying
them together. Is there a way to force a very specific order to be
returned? What I need to be able to do is have a query like

"select * from products where prodID = 'thing1' or prodID = 'thing2'
or prodID = 'thing3'...

but I need it to come back in that EXACT order, product matching
thing1 first thing2 second and so on.


use:
order by fieldname
at the end of your query.

Instead of names, use integer id values in the field which you want to
use for ordering, that way you can easily deside that 'thing1' = 1,
'thing2' = 2, etc, and ordering them is simple and fast.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: vk | last post by:
I have a situation where I have 3 frames. The first frame is dynamic and contains javascript variables for use throughout the frameset page and the other frames. Everything works fine...except...
6
by: tracy | last post by:
I have a complex query (16 table join) that until five days ago took 30 sec to run. It now takes eight hours. I restored a backup of the database from five days ago and the query plans are...
3
by: Clark Spencer | last post by:
I have built a small integration app using VS .NET 2003 that extracts orderinformation from a 'webshop'. Extracting the orderinformation works fine. Appending the order elements in the...
5
by: Jeronimo Bertran | last post by:
I have a DataGrid that gets filled based on a filter which is defined by the values that the user selects on several controls. When the page postbacks after changing the selection on the filter...
0
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button,...
2
by: Oliver Block | last post by:
Hi, I wrote a style to display a web page. Nothing special so far.:) Now I want to force the User Agents to rotate the content by 90°. That is necessary in order to display all data in an...
2
by: Veeru71 | last post by:
Hi, 1) Is it possible to force the join order of the tables in a query (similar to "hints" in Sybase, etc) ? For Example, I am joining 3 tables - A,B & C in my SELECT stmt, and I would like...
3
by: MarkusJNZ | last post by:
Hi, I have two different applications running on 2003 both in two different vitrual directories. One application runs on the .NET framework 1.1 whilst the other runs on 2.0. If I change the...
3
by: beary | last post by:
Is it possible to use an order by statement but force mysql to start with a different entry than the first one? eg. column is "class", which has the possible values "8maths", "10maths", "admaths",...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.