mysql - 在单个查询中从多个表中获取数据

标签 mysql sql database oledb

我有下表作为 LocalBarcode:

enter image description here

和以下为 Barcodecancel enter image description here取消:

我要:

  1. 条码总数

  2. IsUpload 为真的条码数

来自 LocalBarcode 和

  1. isUpload 为 true 的条码数

来自 BarcodeCancel。

我设计了以下查询:

select  localbarcode.(select count(barcode)  
                        from localbarcode 
                       where Int([TimeStamp])= Format(CDate('10/18/2013'))), 
        localbarcode.(select count(isupload)  
                        from localbarcode 
                       where isupload=0), 
        BarcodeCancel.(select count(barcode)  
                        from BarcodeCancel 
                       where Int([TimeStamp])= Format(CDate('10/18/2013'))) 
      from localbarcode,BarcodeCancel

但是这个查询在第一行给我错误。

请帮帮我。

编辑:

enter image description here

最佳答案

    select  (select count(barcode)  
                    from localbarcode 
                   where Int([TimeStamp])= Format(CDate('10/18/2013'))), 
            (select count(isupload)  
                    from localbarcode 
                   where isupload=0), 
            (select count(barcode)  
                    from BarcodeCancel 
                   where Int([TimeStamp])= Format(CDate('10/18/2013'))) 
     from dual

您需要使用虚拟表“dual”。我做了一个简化的尝试:http://sqlfiddle.com/#!2/15291/3

关于mysql - 在单个查询中从多个表中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19448464/

相关文章:

Android joda 时间从 24 转换为 12

mysql 从最后 n 行中选择

sql - ASPX 写入 SQL 数据类型

mysql - 提供每年/每月新客户与回头客的数量

python - 在不同列中打印数据库变量

php - 选择 * 不会在 php mysql 中打印任何内容

mysql - 从一列有多个值的地方选择全部

php更新mysql

sql - 恢复sa密码

批处理文件中未注意到 MySQL MEMORY @@max_heap_table_size