作为开发,你是否经常碰到下面需要转换用户ID成用户名称的情况: 可惜你的这些业务表出于最少冗余设计要求,只有UserId,而没有UserName,这时你不得不破坏你一个类封装一个表的美好想法, 在你的查询写上 1 SELECT a.*,b.Name FROM OrderInfo a LEFT JOIN UserInfo b ON a.UserID=b.ID 你如果用linq的话,可能代码更多一下: 1 2 3 4 5 6 7 8 var query = from A in db.OrderInf…
select a.* from YG_BRSYK a left join(SELECT DISTINCT SYXH, STUFF((SELECT '.'+MS FROM #lsb where SYXH=t.SYXH FOR XML PATH('')),1,1,'') AS MS FROM #lsb as t) c on a.SYXH=c.SYXH WHERE c.MS IS NOT NULL order by RYBQ --注:left join...on 为左关联,保留左边所有的数据,右表…
var haveChange = from newScore in newScoreList join oldScore in oldScoreList on new{newScore.ExamId,newScore.StudentId,newScore.Subject,newScore.ClassId} equals new{oldScore.ExamId,oldScore.StudentId,oldScore.Subject,oldScore.ClassId} where newScore.…