我现在有一个表查询, 要用两个字段来都符合条件 来查询结果
SELECT *
FROM orders
WHERE quantity =1 AND customer = 'Tizag'
现在遇到的问题是
现在我们有一组的的数据 要查询 最简单的做法是Java里写一个循环是
for(int i=0;i<listA.size();i++){
SELECT *
FROM orders
WHERE (quantity =listA.get(0) AND customer = listB.get(0))
}
然后一条一条连接数据库查, 这样速度非常慢
或者写成一条语句
SELECT *
FROM orders
WHERE (quantity =listA.get(0) AND customer = listB.get(0))
OR (quantity =listA.get(1) AND customer = listA.get(1))
OR (quantity =listA.get(2) AND customer = listA.get(2))
这个LIST 可能有100K 条记录 这样就造成了SQL 非常的长。
而一条一条查要100K次
数据库是 oracle
大家有什么其他好的建议没有。谢谢。