mysql - How to cross join a table and use fields from the select statment in the where clause of the cross join -
unfortunately cannot make procedure in case. i'm setting variables in select statement , using them in cross join. count(*) line item
0...
select @p := `purchaseorder`.`po` `po` ,`purchaseorder`.`customer po` ,`customer`.`customer` ,`work_order`.`work order` ,@l := `work_order`.`line order` `line order` ,`line item`.`line item` `work_order` left join `purchaseorder` on `purchaseorder`.`po` = `work_order`.`po` left join `customer` on `customer`.`rn` = `purchaseorder`.`customer` cross join (select count(*) `line item` `work_order` `work_order`.`po` = @p , `work_order`.`line order` <= @l ) `line item` `purchaseorder`.`po` not null order `purchaseorder`.`po`,`work_order`.`line order`
what doing wrong?
thanks pala_
this works!
select @p := `purchaseorder`.`po` `po` ,`purchaseorder`.`customer po` ,`customer`.`customer` ,`work_order`.`work order` ,@l := `work_order`.`line order` `line order` ,(select count(*) `line item` `work_order` `work_order`.`po` = @p , `work_order`.`line order` <= @l ) `line item` `work_order` left join `purchaseorder` on `purchaseorder`.`po` = `work_order`.`po` left join `customer` on `customer`.`rn` = `purchaseorder`.`customer` `purchaseorder`.`po` not null order `purchaseorder`.`po`,`work_order`.`line order`
Comments
Post a Comment