我有这样的partner_stockrecord
表:
"id"|"partner_sku"|"partner_id"
1 sku1 1
2 sku1 2
3 sku2 1
4 sku2 2
5 sku2 3
6 sku3 1
7 sku4 1
SELECT
sku
只有partner_id=1 AND partner_id=2
SELECT
,sku3
如何sku4
只有class BarThread extends Thread {
ClassificationV4 classObj = new ClassificationV4();
JProgressBar progressBar;
public BarThread(JProgressBar bar) {
progressBar = bar;
}
public void run() {
int minimum = 0;
int maximum = classObj.getMaximumLength();
for (int i = minimum; i < maximum; i++) {
try {
int value = progressBar.getValue();
progressBar.setValue(value + 1);
Thread.sleep(classObj.getSleepTime());
} catch (InterruptedException ignoredException) {}
}
}
}
和 //create anonymous thread
new Thread() {
public void run() {
Thread stepper = new BarThread(jProgressBar1);
stepper.start();
}
};
在这种情况下?
P.S。我确信这是一个重复,但我无法制定正确的搜索查询。
答案 0 :(得分:1)
select partner_sku from partner_stockrecord as x
where not exists (
select 1 from partner_stockrecord as y
where x.partner_sku = y.partner_sku and y.partner_id = 1)
union
select partner_sku from partner_stockrecord as x
where not exists (
select 1 from partner_stockrecord as y
where x.partner_sku = y.partner_sku and y.partner_id = 2);
或
select partner_sku from partner_stockrecord
group by partner_sku
having not array_agg(partner_id) @> array[1,2];
或
select partner_sku from partner_stockrecord
group by partner_sku
having count(distinct partner_id) filter (where partner_id in (1,2)) < 2;
只需使用一个对您的数据更有效的方法。