我发现我的应用程序中存在一个错误,该错误中的sql语句未显示正确的结果。我不需要从OR到特定iban的表中的每笔交易:
$limit_offset = ceil(date('W') / 3) - 1;
$query = "SELECT id FROM your_table ORDER BY id LIMIT $limit_offset, 3";
目前,它仅显示来自所选iban的交易,事实是也有传入的交易:
SELECT *
FROM BANKING.TRANSTAB
WHERE ABSENDER = 'DE71419330598239161300'
OR EMPF = 'DE71419330598239161300'
AND
TIME BETWEEN TO_DATE('2018-10','YYYY-MM')
AND TO_DATE('2018-12','YYYY-MM');
------+---------+---------+---------+---------+---------+---------+---------+---------+---
ROW_ID ABSENDER EMPF SUMME ZWECK
------+---------+---------+---------+---------+---------+---------+---------+---------+---
98 DE71419330598239161300 DE38820942858809256538 10.45 test
99 DE71419330598239161300 DE38820942858809256538 23.42 test
102 DE71419330598239161300 DE38820942858809256538 12.00 123
103 DE71419330598239161300 DE38820942858809256538 12.00 12
104 DE71419330598239161300 DE38820942858809256538 12.00 123
105 DE71419330598239161300 DE38820942858809256538 123.00 123
答案 0 :(得分:1)
如果使用OR,则需要在方括号内使用所有OR条件。
SELECT * FROM BANKING.TRANSTAB
WHERE (ABSENDER = 'DE71419330598239161300'
OR EMPF = 'DE71419330598239161300')
AND
TIME BETWEEN TO_DATE('2018-10','YYYY-MM')
AND TO_DATE('2018-12','YYYY-MM');