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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.