employee(id, name)
payroll(name, salary)
SELECT employee.id, employee.name, payroll.salary
FROM employee left OUTER JOIN payroll
ON employee.name like payroll.name + '%'
从这两个表中获取不匹配的记录。有什么想法吗?
答案 0 :(得分:0)
您可以尝试此查询:
var query = from emp in context.employee
join res in (from emp in context.employee
from pay in context.payroll
where emp.name.StartsWith(pay.name)
select new
{
emp.id,
pay.salary
})
on emp.id equals res.id into subRes
from sub in subRes.DefaultIfEmpty()
select new
{
emp.id,
emp.name,
sub?.salary
};