Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
比较android中的两个ArrayList_Android_Arraylist_Sqlite_Compare - Fatal编程技术网

比较android中的两个ArrayList

比较android中的两个ArrayList,android,arraylist,sqlite,compare,Android,Arraylist,Sqlite,Compare,我有两个名为ArrayList 1和ArrayList 2的ArrayList Arraylist1 having fileds instock,Productcode,productname,batchnNo,saledQty,discount and amount, Which stores values from database table named ProductDetails. Arraylist2 having fields Productcode,minQuantity,ma

我有两个名为ArrayList 1ArrayList 2的ArrayList

Arraylist1 having fileds instock,Productcode,productname,batchnNo,saledQty,discount and amount, Which stores values from database table named ProductDetails.

Arraylist2 having fields Productcode,minQuantity,maxQuantity,discount,discountType, which stores values from different table  named DiscountDetails.
我们需要根据产品代码比较ArrayList 1和ArrayList 2。如果产品代码相同,则我需要检查特定产品代码的销售数量
从ArrayList 1,我们需要检查它是否会落在ArrayList 2的minQuantity和maxQuantity之间。(minQuantity您是否尝试在数据库SQL查询端解决此问题。这可以很容易地放入SQL查询中

针对否决票进行编辑:

尝试此SQL,而不是处理两个列表。如果
saledqty
介于最小值和最大值之间,则此SQL将提供所有带有折扣代码的产品,否则将提供任何产品。折扣

select p.instock, p.Productcode, p.productname, p.batchnNo, p.saledQty, p.amount, 
        isnull(d.discount, p.discount)
from 
    ProductDetails p
left join 
        DiscountDetails d on p.Productcode = d.Productcode 
        and p.saledQty between d.minQuantity and d.maxQuantity

如果只对具有有效折扣的产品感兴趣,则将
左联接(外部联接)更改为
联接(内部联接)。

您是否尝试在数据库SQL查询端解决此问题。这可以很容易地放入SQL查询中

针对否决票进行编辑:

尝试此SQL,而不是处理两个列表。如果
saledqty
介于最小值和最大值之间,则此SQL将提供所有带有折扣代码的产品,否则将提供任何产品。折扣

select p.instock, p.Productcode, p.productname, p.batchnNo, p.saledQty, p.amount, 
        isnull(d.discount, p.discount)
from 
    ProductDetails p
left join 
        DiscountDetails d on p.Productcode = d.Productcode 
        and p.saledQty between d.minQuantity and d.maxQuantity

如果只对具有有效折扣的产品感兴趣,则将
左连接
(外部连接)更改为
连接
(内部连接).

你能告诉我们你尝试过什么吗?对不起。事实上我对java非常陌生。我不知道如何实现这个概念。这就是我为什么要发布这个问题。请坦率地帮助我,这有点像家庭作业。正如下面的回答所指出的,这一切都可以用SQL完成,否则你需要看看Android
Cursor
类,也许。你真的需要一些代码才能在这里得到任何具体的帮助。你能告诉我们你尝试了什么吗?对不起。事实上,我对java非常陌生。我不知道如何实现这个概念。这就是为什么我要发布这个问题。坦率地说,请帮助我,这有家庭作业的味道。正如下面的答案所指出的,这一切都可能是错误的在SQL中完成,否则您可能需要查看Android
Cursor
类。在获得任何具体帮助之前,您确实需要一些代码。