Once I execute split, im hoping to see the following 3 things:
My query below gets most of this right except for point 2, as it only returns transactions 5 and 6 instead of the full list. What can I change?
SELECT * FROM customers c
INNER JOIN transactions t ON c.custid = t.custid
INNER JOIN purchaces p ON t.transid = p.transid
WHERE c.customer = 1234 AND t.trans_num IN (5,6)
ORDER BY t.trans_num
You are explicitely filtering for records 5 and 6 in your where statement. You can LEFT JOIN the purchases table using that condition. You will get all transactions, but the purchases columns will be NULL if they don't belong to transactions 5 or 6.
SELECT *
FROM customers c
INNER JOIN transactions t
ON c.custid = t.custid
LEFT JOIN purchaces p
ON t.transid = p.transid
AND t.trans_num IN (5,6)
WHERE c.customer = 1234
ORDER BY t.trans_num
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.