473,414 Members | 1,744 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,414 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 2473
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.