问题描述
我现在有两张表一张员工表一张部门表employee:iddepartmenrtidnamedepartment:idsort我现在查询员工表要通过departmentid和name两个字段排序期中departmentid的排序方法是根据department表中的sort来排序的急急急希望各路神仙帮帮忙万分感谢
解决方案
解决方案二:
select*fromemployee,departmentwhereemployee.departmenrtid=department.idorderbydepartmenrtidsortasc,employee.idasc
解决方案三:
select*fromemployeeejoindepartmentdone.departmenrtid=d.idorderbye.nameasc,d.sortasc
解决方案四:
该回复于2012-03-19 14:32:10被版主删除
解决方案五:
select*fromemployeeeorderby(selectsortfromdepartmentwheree.departmentid=department.id)asc,nameasc
解决方案六:
selecte.*fromemployeeeleftjoindepartmentdone.departmenrtid=d.idorderbyd.sortasc,e.nameasc
解决方案七:
selecte.*fromemployeeeleftjoindepartmentdone.departmenrtid=d.idorderbyd.sortasc,e.nameasc
解决方案八:
这么多答案,lz不要凌乱了
解决方案九:
该回复于2012-03-19 15:19:41被版主删除
解决方案十:
各位的我都试过了查出来的结果都稍微有点差排序的时候name字段干预到departmentid了例如:有三条数据是这样的employee:iddepartmentidname183D36C5D-9C96-4B86-A80B-F66355C03A79系统管理员28802659F-D5EF-4D8E-BFD0-FFE5C058850F张武装383D36C5D-9C96-4B86-A80B-F66355C03A79张孝南可能是我没说清楚我想要的结果是先以departmentid来排序然后针对属于这个department的员工进行名字上的排序不好意思
解决方案十一:
select*fromemployee,departmentwhereemployee.departmenrtid=department.idorderbydepartmenrtidsortasc,employee.nameasc