如何在内部连接中使用distinct与order by [英] how to use distinct in innerjoin with order by
本文介绍了如何在内部连接中使用distinct与order by的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两张桌子
一张主键有列
empid,empname
秒有外键的列
empid,empdoj,empclient,empstatus
具有重复值的外键表
i有两个连接两个表并选择不同的行使用加盟日期的顺序
请帮帮我
解决方案
我有两个连接两个表并选择不同的行使用加盟日期的顺序
不太确定,但听起来你需要这个:
SELECT
mstEmployees.empid,
mstEmployeesDetails.empname,
mstEmployeesDetails.empclient,
mstEmployeesDetails.empstatus
FROM
mstEmployees
INNER JOIN
mstEmployeesDetails ON mstEmployees.empid = mstEmployeesDetails.empid
ORDER BY
mstEmployeesDetails.empdoj
i have two tables
one having primary key with columns
empid,empname
second having foreign key with columns
empid,empdoj,empclient,empstatus
foreign key table having duplicate values
i have two join two table and select distinct row using the order of emp date of joining
please help me
解决方案
i have two join two table and select distinct row using the order of emp date of joining
Not too sure, but sounds like you need this:
SELECT mstEmployees.empid, mstEmployeesDetails.empname, mstEmployeesDetails.empclient, mstEmployeesDetails.empstatus FROM mstEmployees INNER JOIN mstEmployeesDetails ON mstEmployees.empid = mstEmployeesDetails.empid ORDER BY mstEmployeesDetails.empdoj
这篇关于如何在内部连接中使用distinct与order by的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文