t6.sql 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. select count(*) from(
  2. select t.*, IFNULL(pr.reportery,0) reporteryQ
  3. from (
  4. SELECT
  5. CONCAT('uploads/thumbnail/',ep.`picpath`,'/',ep.`newpicname`) picpath,
  6. CONCAT('uploads/image/',ep.`picpath`,'/',ep.`newpicname`) srcpath,
  7. b.`brandName`,c.`id`,c.`brand`,c.`brandId`,c.`partCode`,c.`partId`,c.`partName`,c.`pastureId`,c.`pastureName`,
  8. TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM c.`price`))) price,
  9. c.`specification`,c.`unit`
  10. FROM
  11. contract c
  12. LEFT JOIN part_repertory pr ON c.id = pr.contractId
  13. LEFT JOIN warehouse w ON pr.locationId =w.id
  14. LEFT JOIN brand b ON b.id = c.brandId
  15. LEFT JOIN bigcontract bc ON bc.id = c.bigId
  16. LEFT JOIN bigcontract bc2 ON bc2.contractCode = left(bc.contractCode,12)
  17. join pasture_bigcontract pbt on pbt.bigcontract_id =bc2.id
  18. LEFT JOIN parts ps ON ps.id = c.partId
  19. LEFT JOIN eq_pic ep ON ep.id = ps.picpath
  20. WHERE
  21. bc.`providerId` = 1971 AND c.enable = 1
  22. AND bc.`stopTime`>=DATE_FORMAT( NOW(),'%Y-%m-%d')
  23. and bc.statue=1 and bc.SHStatus = 7
  24. AND if(''='' ,bc.SHStatus = 7,c.`partCode` ='' OR c.`partName` = '' OR c.`specification` ='')
  25. and (bc.pastureId = 18 or '' = 18 or pbt.pasture_id = 18)
  26. )t
  27. left join
  28. (
  29. select reportery,contractId from part_repertory pr2 left join warehouse w on pr2.locationId =w.id
  30. where pr2.pastureId = 18 or (pr2.pastureId = 18 and w.pastureId = 18) limit 10
  31. ) pr ON pr.`contractId` = t.`id`
  32. )a