Javascript - 如何显示包含常见数据的多个字段的详细信息? [英] Javascript -how to display the details of a multiple field with common data in it?

查看:83
本文介绍了Javascript - 如何显示包含常见数据的多个字段的详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

transaction.executeSql('SELECT t1.*,t2.Cust_name FROM invoice t1,customer t2 where t2.Cust_name="'+rname+'" and t1.Cust_code=t2.UserId', [],  function(transaction, result)
                                {
                                  le=result.rows.length;
                                  for (var i = 0; i < result.rows.length; i++)
                                      {
                                       var row = result.rows.item(i);
                                          rid=row.Invoice_number;
                                          console.log(rid);
                                          if(rid)
                                           document.location.href="invoice_data_list.html?rname="+rname+"&rid="+rid;
                                           console.log("s");
                                       }

                                   });



这是从两个表中选择数据的代码,下面是表格描述。 />
table1-invoice(invoice_id,date,cust_code,amt)

table2-customer(userid,custname,bal_amt);



我有相同和不同客户的发票清单。点击特定发票后,它应该在另一页显示它的详细信息。这是我的工作。

这里的问题是:如果我选择一个有多张发票的客户,它会显示特定客户的最后一张发票。如果我点击一张有单张发票的客户,那么它会显示正确的详细信息。

如何获得解决方案请...


This is a code to select datas from two tables,below are the table descriptin.
table1-invoice(invoice_id,date,cust_code,amt)
table2-customer(userid,custname,bal_amt);

I have a list of invoices for the same and different customers.On clicking a particular invoice it should display the details of it in another page.That is my work here.
The problem here is:If I select a customer who has multiple invoices it displays the last invoice of the particular customer.If I click on a customer having a single invoice then it displays the correct details.
How can I get a solution please...

推荐答案

您好,



请使用以下查询:

Hello,

Please use following query:
SELECT i.invoice_id, i.date, i.amt, c.custname, c.bal_amt FROM invoice i
INNER JOIN customer c ON i.cust_code = c.userid WHERE c.Cust_name="rname"


这篇关于Javascript - 如何显示包含常见数据的多个字段的详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆