sql - MYSQL - get lowest bid from table group by product (results weird) -
ok, baffled going on query trying following: lowest bid grouped product_id , load in product information related bid.
currently when running below query says me bid_id column product_id = 2 30 definetly not 30, should 120 (although bid_price value correct @ 29.99):
select lowbid.bid_id, lowbid.bid_price (select bid_id, min(bid_price) bid_price, product_id tbl_products_bid is_active = 1 , is_deleted = 0 group product_id) lowbid;
now due query giving me random bid_id's, not sure why wondering if sql guru provide me insight 1. if being totally thick or 2. if there way or why getting random bid_id not related bid_price.
i have created sqlfiddle can explain mean grateful.
http://sqlfiddle.com/#!2/de77b/14
also let know query part of query took out element think giving me issue (i.e above) part of bigger query below:
select lowestbid.bid_id, lowestbid.product_id, lowestbid.bid_price seller_bid_price, seller_description, pb.is_countdown, pb.startdate, pb.enddate tbl_products_bid pb inner join ( select bid_id, product_id, min(bid_price) bid_price, seller_id, description seller_description, is_countdown, startdate, enddate tbl_products_bid is_active = 1 group product_id ) lowestbid on pb.bid_id = lowestbid.bid_id order lowestbid.bid_price asc
select a.* tbl_products_bid inner join ( select product_id, min(bid_price) min_price tbl_products_bid group product_id ) b on a.product_id = b.product_id , a.bid_price = b.min_price
Comments
Post a Comment