以下是一般搜索的代码:
int row = jTable_accounts.getSelectedRow();
String Table = (jTable_accounts.getModel().getValueAt(row, 0).toString());
String sql ="select c.customer_id as 'Customer No.', customer_name as 'Name',a.account_id as 'Account No.',DIA,a.balance as 'Current Balance',a.outstanding_amt as'Outstanding Amt.' from customer c inner join customer_details cd on cd.customer_id=c.customer_id inner join account a on a.customer_id=c.customer_id where a.account_id= '"+Table+"' ";
因此结果将显示在 jtable 中,但是,我想添加 4 或 5 个文本框,它们应根据客户名称、未结金额等过滤结果。这些文本框应该是可选条目,如果用户没有在应用程序应显示一般输出的任何文本框中输入任何值(上述代码)。
我认为应该在 select 语句中添加一些 where 子句,但我不确定它应该如何是可选的。
这些是三个表格以获取更多信息:
顾客:
customer_id DIA customer_name birth_date
-------------- ------ ------------------------ -------------
1 32 Ahmad mohammad bin afif (null)
2 10 mohammad ahmad bin afif (null)
顾客信息:
customer_id phone_no1 phone_no2 address_line1 address_line2
-------------- ------------ ------------ ---------------- ----------------
1 0111231415 019123443 bukit (null)
2 01345532 (null) kl serdang
帐户:
account_id balance outstanding_amt customer_id
------------- ---------- ------------------ --------------
1 12530.23 1821.3 1
2 2040.13 125.3 1
3 213455 1234.3 2