Fallback condition in a mysql select statement -
i want put condition mysql statement. if possible?
this current mysql select statement
select * `validproduct` `visible` = 1 , `typeid` = 2 , `sizeid` = 3 group `productid`
so @ moment, selecting products sizeid = 3. want select products size = 1, , if doesn't exist, select sizeid = 3.
my validproducts table contains list of products 6 different sizes associated (which in turn have different pricing). want return of products, lowest sizeid (which have lowest price available product). not products have sizeid 1.
so return data product (sizeid 1, $x); product b (sizeid 3, $y) etc
here way it:
select vp1.* validproduct vp1 inner join ( select productid, min(sizeid) minsize validproduct visible = true , typeid = 2 group productid ) vp2 on vp1.productid = vp2.productid , vp1.sizeid = vp2.minsize , vp1.visible = true , vp1.typeid = 2 group vp1.productid;
explanation:
the outer query have. inner sub-query finds minimum sizeid every product. joining 2 want.
Your Affiliate Money Printing Machine is waiting -
ReplyDeletePlus, getting it running is as easy as 1, 2, 3!
This is how it all works...
STEP 1. Input into the system which affiliate products you intend to promote
STEP 2. Add PUSH BUTTON TRAFFIC (this LITERALLY takes 2 minutes)
STEP 3. Watch the system grow your list and sell your affiliate products all by itself!
Are you ready to start making money???
You can test-drive the system for yourself risk free...
Hhh
ReplyDelete