-
-
Notifications
You must be signed in to change notification settings - Fork 791
Open
Description
In my database all tables have key Id. How should I join tables correctly?
For example, right now I'm trying to join the Users and Companies tables like this:
export class UserService<ServiceParams extends Params = UserParams> extends KnexService<User, UserData, UserParams, UserPatch> {
createQuery(params: UserParams) {
const query = super.createQuery(params)
query
.leftJoin('Companies', 'Users.CompanyId', 'Companies.Id')
.select('Companies.Name as CompanyName')
return query
}
}
Unfortunately I get an error message:
select [Users].*, [Companies].[Name] as [CompanyName] from [Users] left join [Companies] on [Users].[CompanyId] = [Companies].[Id] where [Id] = @p0 and [Users].[Id] = @p1 - Ambiguous column name 'Id'.
In the where section it is '[Id] = ' instead of '[Users].[Id] = '. What am I doing wrong?
Metadata
Metadata
Assignees
Labels
No labels