I have two tables Transaction Table :-
1 txn_id
2 txn_issued_by (mid)
3 dist_id
4 amount
5 bank_name
6 account_no
7 ben_name
8 ben_contact
9 date_of_transaction
10 date_of_txn_modify
11 txn_status
12 bank_response_code
13 status
14 modify_by
15 comm_amount_agent
16 comm_amount_distributor
17 comm_amount_sadmin
18 client_name
19 client_number
20 client_add
21 txn_serial_no
22 comment_by_moderator
2)Member Table
- mid name username photo
我只是想知道如何处理交易以获得想要的结果,比如......
- 获取金额介于 525 t0 2500 之间的交易数量
- 获取金额介于 2501 t0 5050 之间的交易数量
获取金额介于 5051 t0 10100 之间的交易数量
在所有用户(用户明智)中,我的代码是:
<?php
$q_c = "SELECT *,
COUNT(txn_id) AS count_txn
FROM TRANSACTION
WHERE amount >= 525
AND amount <= 2500
AND txn_issued_by IN (
SELECT mid
FROM members
)
GROUP BY txn_issued_by";
$r_c = mysql_query($q_c) or die(mysql_error());
$row_c = mysql_fetch_array($r_c);
$count_txn = $row_c['count_txn'];
?>
目标如下: