MySQL SubQuery Conditional -
i trying build rather complex view in mysql , want conditional, sems fail.
my view (simplified) is
select entry entry, ,(select count(`poitems`.`entry`) `count(poitems.entry)` `poitems` (`poitems`.`purchaseorder` = `purchaseorder`.`entry`)) `totalentries`, purchase orders this ok trying add like
if ((select count(`poitems`.`entry`) = 0),'query.png',null) queryflag or test value of totalentries.
help appreciated! thanks!
i'm not 100% sure on names of columns in purchaseorder or poitems tables following should headed in right direction:
select t.entry, case when t.totalentries > 0 'query.png' else null end queryflag ( select po.entry entry, count(*) totalentries purchaseorder po left outer join poitems poi on poi.purchaseorder = po.entry group po.entry ) t;
Comments
Post a Comment