Untitled

mail@pastecode.io avatar
unknown
mysql
a year ago
736 B
3
Indexable
Never
SELECT 
    r.reasoncode,
    i.createdate AS removedate,
    s.serialnumber,
    s.product,
    size,
    location,
    SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(s.notes, ']', 1),
                    'by',
                    - 1),
            ',',
            1) User,
    SUBSTRING_INDEX(s.notes, ']', 1) notes
FROM
    (SELECT 
        serialnumber, createdate, productcode, inventoryupdateid
    FROM
        inventoryupdate_extend
    WHERE
        DATE(createdate) = CURDATE()) i
        JOIN
    inventoryitem s ON s.serialnumber = i.serialnumber
        AND s.notes LIKE '[Manual Decrement%'
        AND DATE(removedate) = CURDATE()
        JOIN
    inventoryupdate r ON r.id = i.inventoryupdateid
ORDER BY removedate ASC