Jump to content

[SOLVED] Finding larger of 2 columns?


triphis

Recommended Posts

Hi there everyone ;)

 

Simple featured item script for an online store... Items have 2 columns, RETAIL and SALE (price, that is).

 

There is the option for the store owner to have the featured item to be the most expensive one... and I originally wrote the query to select the largest by RETAIL. However, obviously if that item is on sale for much less, it might not be the most expensive...

 

So, what I need is this:

 

SELECT id, LARGER(RETAIL,SALE) as highest FROM products ORDER BY highest DESC LIMIT 1

 

-------------------------------------

 

Is there a function to choose the larger of two as I have done above???

Thanks!!!

Link to comment
https://forums.phpfreaks.com/topic/50086-solved-finding-larger-of-2-columns/
Share on other sites

Nope :)

 

I see my mistake.

 

Okay, let me try again: The items will not always be on sale (SALE = 0). However, if they are, then the SALE price is the price that the customer would pay, not the RETAIL price. So just ordering by RETAIL price would not be appropriate.

 

I am looking for a way to rank all by the price that *would* be paid by the customer, to find the actual most expensive item.

 

---------------------

 

Scenario:

 

Item 1 - retail=$300 / sale=$200

Item 2 - retail=$250 / sale=$0

 

I want my query to find Item 2 to be the most expensive :)

 

I hope that clears things up, and I hope you can still help me ^^

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.