sql - MYSQL create a subquery -
i'm trying write msyql query i'll find items have closed & sold not yet charged customer.
basically, have catalog_item product, , once catalog item closes, charge customer, , record in our customer_order table (there's column called catalog_item_id can join on).
so need to:
1) find active items closed bids (covered below in code),
2) join customer_order, @ orders , reject catalog_items in first part of query have order.
the first part of query written below, second part of query goes past sql knowledge , believe requires subquery. welcome in advance!!!!
select * catalog_item ci left outer join customer_order co on co.catalog_item_id = ci.catalog_item_id ci.close_date < now() , ci.active = 1 , ci.bid_count > 0
if want "get rid of catalog items have orders", want check left join
doesn't find anything:
select * catalog_item ci left outer join customer_order co on co.catalog_item_id = ci.catalog_item_id ci.close_date < now() , ci.active = 1 , ci.bid_count > 0 , co.catalog_item_id null;
Comments
Post a Comment