VbzCart/queries/qryPkgs Pull status

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

About

  • Notes: This query is very slow (40-45 seconds to execute)
  • History:
    • 2009-07-10 Adapted from MS Access

SQL

<mysql>CREATE OR REPLACE VIEW qryPkgs_Pull_status AS SELECT

 ps.*,
 pu.ID_Type AS ID_PullType,
(pu.ID_Ord IS NOT NULL) AS IsPulled,
 IF(b.Name=r.Name,b.Name,CONCAT_WS("->",b.Name,r.Name)) AS CustName,
 IF((ar.Country IS NULL) OR IFNULL(ar.Country,"")="us",ar.Zip,ar.Country) AS Zone,
 o.ID_NameBuyer,
 o.ID_NameRecip

FROM

 (
   (
     (
       (qryPkgs_status AS ps LEFT JOIN qryOrders_Pulled AS pu ON ps.ID_Order = pu.ID_Ord)
       LEFT JOIN core_orders AS o ON ps.ID_Order=o.ID)
     LEFT JOIN qryCbx_CustNames AS r ON o.ID_NameRecip=r.ID)
   LEFT JOIN qryCbx_CustNames AS b ON o.ID_NameBuyer=b.ID)
 LEFT JOIN cust_addrs AS ar ON ar.ID=o.ID_ContactAddrRecip

ORDER BY o.Number;</mysql>