Jump to content

Complex Order


EagerWolf

Recommended Posts

Hi!

 

I am looking for salvation for my complex data ordering in MySQL.

 

I have options:

price (price in EURos) and price_1 (ENUM - 0, 1)

 

Example:

case1:

price = 1400

price_1 = 0

 

case2:

price = 1400

price_1 = 1

 

case3:

price = NULL

price_1 = 1

 

If is price_1 = 0 and price = 1400, than it is printed: 1400 $

The point is if is set price_1 = 1 and is set price (1400), than it is shown like this: Call for price (cca 1400).

If price_1 = 1 and price = NULL, than it is printed just Call for price.

 

And what I want to set is that values with price 0 or NULL are listed in the end of results.

 

Let us say we have table like this:

ID

price

price_1

1

1400

1

2

0

1

3

1200

1

4

1300

0

5

800

0

 

I want output to list me records in order by price with price = 0 in the end. So the proper order would be (by IDs): 5, 3, 4, 1, 2

 

And records must be stored in the same query... I don't want to make two queries for this.

 

Thanks for your help!

 

 

Link to comment
https://forums.phpfreaks.com/topic/107855-complex-order/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.