
May 4th, 2008, 03:34 PM
|
 |
Contributing User
|
|
Join Date: Jan 2001
Location: Cheltenham, UK
Posts: 146
Time spent in forums: 1 Day 31 m 12 sec
Reputation Power: 8
|
|
|
Ordering by price value asc in joined table
Hi There,
I getting a little confused with this one and would appreciate any pointers anyone can give me.
Code:
SELECT distinct p.pid, p.cid, p.name FROM p LEFT OUTER JOIN pcx ON p.pid=pcx.pid LEFT OUTER JOIN pxo ON p.pid=pxo.pid WHERE (p.cid='$cid' AND p.publish='Y') OR (pcx.cid='$cid' AND p.publish='Y')ORDER BY pxo.price ASC LIMIT $position, $nresults
trouble is this bit:
Code:
ORDER BY pxo.price ASC
Some of the rows have 2 values for the price and I need to order by the lowest of the two values.....By default (with my query) it orders by the higher of the two values which means that my results are out of sync.
I hope i explained right!
Thanks for any pointers!
|