我这里有2个SQL连接,一个返回好结果,另一个返回0结果集。 为什么会这样?除了连接/列/表顺序之外,它们非常相似。 (顺便说一句,我在这里使用MySQL)
工作加入(返回超过240,000行良好数据)
SELECT
t1.email AS "email",
t1.record_id AS "record_id",
t2.status AS "status",
t3.item_record_id AS "item_record_id",
t1.ordered_at AS "started_at"
FROM `rs_orders` t1
INNER JOIN `cb_all_transactions` t2
ON t1.record_id = CONCAT('cb_sl_', t2.receipt)
INNER JOIN `rs_order_items` t3
ON t1.record_id = t3.order_record_id
WHERE t2.recurring = 'true'
ORDER BY t1.ordered_at ASC
非工作加入(返回0行)
SELECT
t1.email AS "email",
t1.record_id AS "record_id",
t1.ordered_at AS "started_at",
t2.item_record_id AS "item_record_id",
t3.status AS "status"
FROM rs_orders t1
INNER JOIN rs_order_items t2
ON t1.record_id = t2.order_record_id
INNER JOIN cb_all_transactions t3
ON t2.order_record_id = CONCAT('cb_sl_' + t3.receipt)
WHERE t3.recurring = 'true'
答案 0 :(得分:5)
他们不一样。第二个是CONCAT('cb_sl_' + t3.receipt)
。将+
替换为,
。