首页 新闻 会员 周边 捐助

两个sql查询语句合成一个。

1
悬赏园豆:20 [已解决问题] 解决于 2016-04-13 16:11
select a.CardID,a.EmployeeID,a.EmployeeName,b.DateTimeBrush,a.SexID,c.DepartmentName from TC_Employee a
left join AT_CardBrushRecord b  on a.CardID=b.CardId
left join TC_Department c on a.DepartmentID=c.DepartmentID
where  c.Departmentname='asd' and b.DateTimeBrush between 2010-04-07 14:02:50.020 and 2016-04-07 14:02:50.020
group by a.CardID,a.EmployeeID,a.EmployeeName,b.DateTimeBrush,c.DepartmentName


select COUNT(a.CardID) from TC_Employee a
left join TC_Department b on a.DepartmentID=b.DepartmentID
where a.DepartmentID=1




        public DataTable GetEmp()
        {
            string sql = "select a.CardID,a.EmployeeID,a.EmployeeName,b.DateTimeBrush,c.DepartmentName,  from TC_Employee a  " +
                         "left join AT_CardBrushRecord b on a.CardID=b.CardId " +
                         " left join TC_Department c on a.DepartmentID=c.DepartmentID " ;
            
                                    
                        
          return  YC.Common.SqlDataAccess.GetDataTable(sql);
        }

就是上面的两个数据库里里面的查询语句,要怎么弄到程序里,作为一个sql语句啊 

菜鸟、编程的主页 菜鸟、编程 | 初学一级 | 园豆:93
提问于:2016-04-11 17:05
< >
分享
最佳答案
0

你想显示的数据是一个对象还是一个集合

收获园豆:20
渴死的鱼丶 | 初学一级 |园豆:124 | 2016-04-11 17:53

是显示在水晶报表里面的数据,是一个对象

菜鸟、编程 | 园豆:93 (初学一级) | 2016-04-11 17:55

@菜鸟、编程: string sql = "select a.CardID,a.EmployeeID,a.EmployeeName,b.DateTimeBrush,c.DepartmentName,

(string sql = "select a.CardID,a.EmployeeID,a.EmployeeName,b.DateTimeBrush,c.DepartmentName, from TC_Employee a " + "left join AT_CardBrushRecord b on a.CardID=b.CardId " + " left join TC_Department c on a.DepartmentID=c.DepartmentID " ) as count

from TC_Employee a " + "left join AT_CardBrushRecord b on a.CardID=b.CardId " + " left join TC_Department c on a.DepartmentID=c.DepartmentID " ;  这样应该是可以的

渴死的鱼丶 | 园豆:124 (初学一级) | 2016-04-11 18:00

@渴死的鱼丶: 报错额 

菜鸟、编程 | 园豆:93 (初学一级) | 2016-04-11 18:09

@菜鸟、编程: 先放数据库调试一下 看看什么问题先

渴死的鱼丶 | 园豆:124 (初学一级) | 2016-04-11 18:22

找网站渗透检测高手,月保5万以上。

QQ87376621 | 园豆:206 (菜鸟二级) | 2016-04-11 23:24

找网站渗透检测高手,月保5万以上。

QQ87376621 | 园豆:206 (菜鸟二级) | 2016-04-11 23:24

@渴死的鱼丶: 放数据库说是有语法错误

菜鸟、编程 | 园豆:93 (初学一级) | 2016-04-12 09:11
其他回答(2)
0

找网站渗透检测高手,月保5万以上。

QQ87376621 | 园豆:206 (菜鸟二级) | 2016-04-11 23:24
0

直接放进去,在第一句后面加个英文分号,用dataset接收

lb1208 | 园豆:371 (菜鸟二级) | 2016-04-12 21:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册