我需要一些SQL帮助来尝试查找表中没有的内容

时间:2015-05-22 15:51:24

标签: sql sql-server tsql

我需要一些帮助。我试过这个并没有用。 我选择了我需要的所有数据并尝试说出了什么不在 原始文件。

有人能告诉我正确的方法吗?

 SELECT * 
    FROM acknowledgement t1
    where t1.st01 = '110' 
    and (t1.shipment ='S640D14268424' or t1.Shipment ='S640D14268924' or
      t1.Shipment ='S640D14268925' or t1.Shipment ='S646D14261190' or
      t1.Shipment ='S646I14265886' or t1.Shipment ='S640D14268423' ...)
   AND [shipment] 
   NOT IN(
   SELECT [shipment] FROM acknowledgement 
   )

任何帮助都会有用。

1 个答案:

答案 0 :(得分:-1)

您正在寻找类似的内容:

public Cursor calculate(String month){
        return db.rawQuery("Select " + "sum(" + CN_GA + ")" +
                " from " + TABLE_NAME + " where strftime('%m', " + CN_DATE + ") = '" + month +"'", null);
    }

更好的方法是创建一个临时表来存储要检查的数字。