The query to three table, with the help of a number of calculations, need superimposed later as a result of conditions, but the reference to the Id, the main table below has been submitted to the unknown fields
is the great god what is the solution? Get a can achieve the same effect of SQL statement
CodePudding user response:
The SELECT w. *The FROM i_quality_control w
WHERE w.i nventory_organization_id=3605376833355776
AND baron tatus IN (3, 5)
AND w.w arehouse_id=4222032529260544
AND the EXISTS
(SELECT d.i d
The FROM i_quality_control_detail d
WHERE d.q uality_control_id=w.i d
AND d.p assed_qty & gt; 0 AND d.i s_inbound=0)
AND (
Select count (*) from (
The SELECT QCD. Id
The FROM i_quality_control_detail QCD
WHERE QCD. Quality_control_id=w.i d
AND QCD. Passed_qty & gt; 0 AND QCD. Is_inbound=1
The union
SELECT bg. Quality_control_detail_id
The FROM i_barcode_generator bg
WHERE bg. Quality_control_id=w.i d
AND bg. Doc_from=2
The union
SELECT the up. Quality_control_detail_id
The FROM i_unqualified_product up
The WHERE up. Quality_control_id=w.i d) as Tmp
)
<>
(SELECT count (*)
The FROM i_quality_control_detail d2
WHERE d2. Quality_control_id=w.i d) order by id LIMIT 10
have a great god help have a look