SELECT
t3.transaction_id,
t3.transaction_no,
t3.retrivel_ref_no,
t3.transaction_type,
t3.reversal_flag,
t3.expires_on,
t3.currency_code,
t3.message_reason_code,
t4.sales_person_id,
t3.card_no,
t3.transaction_amount,
t3.transmission_date_time
FROM TRANSACTION AS t4
INNER JOIN
( SELECT
t2.transaction_id,
t2.transaction_no,
t2.retrivel_ref_no,
t2.transaction_type,
t2.reversal_flag,
t2.transmission_date_time,
t2.transaction_amount,
t2.card_no,
t2.expires_on,
t2.currency_code,
t1.message_reason_code
FROM
( SELECT*
FROM transaction_pci_details
WHERE message_reason_code LIKE '%OUT%'||
message_reason_code LIKE '%FAILED%'
) AS t1
INNER JOIN
(
SELECT*
FROM transaction_pci_details
WHERE action_code LIKE '%REQ%'
) AS t2
ON t1.transaction_no = t2.transaction_no
) AS t3
ON t4.transaction_id = t3.transaction_id;
答案 0 :(得分:1)
(SELECT* FROM transaction_pci_details WHERE
message_reason_code LIKE '%OUT%'|| message_reason_code LIKE '%FAILED%') AS t1
INNER JOIN
(SELECT* FROM transaction_pci_details WHERE
action_code LIKE '%REQ%' ) AS t2
ON t1.transaction_no = t2.transaction_no
可以简化为
SELECT* FROM transaction_pci_details as t1, transaction_pci_details as t2 WHERE
(t1.message_reason_code LIKE '%OUT%'|| t1.message_reason_code LIKE '%FAILED%')
AND t2.action_code LIKE '%REQ%'
AND t1.transaction_no = t2.transaction_no
没有INNER_JOIN
。
也许你可以通过这种方式摆脱其他INNER_JOIN
。
你也可以通过写SELECT
SELECT * FROM mytable
后的lisis